return log in unicode
966108
def format(self, record):
        
        self._format_record(record)

        record_dict = {}
        for k, v in record.__dict__.items():
            if isinstance(k, str):
                k = decode_(k, 'utf8')
            if isinstance(v, str):
                v = decode_(v, 'utf8', 'replace')
            record_dict[k] = v

        if 'color' in self.fmt or 'end_color' in self.fmt:
            record_dict['color'], record_dict['end_color'] = _color(record.levelno)

        log = self.ufmt % record_dict

        if record.exc_text:
            if log[-1:] != '\n':
                log += '\n'
            log += decode_(record.exc_text, 'utf8', 'replace')

        log = log.replace('\n', '\n' + self.tab)

        return log
228359
def dump_logs(self):
        
        msg = "log dump: \n"
        if self._transcribe:
            if self._transcribe_queue:
                while not self._transcribe_queue.empty():
                    logs = self._transcribe_queue.get()

                    if isinstance(logs, six.binary_type):
                        logs = logs.decode(encoding='UTF-8', errors="ignore")

                    msg = '{0} {1}'.format(msg, logs)
        else:
            logs = self.client.logs(self.id, stdout=True, stderr=True, stream=False, timestamps=False, tail='all')
            if isinstance(logs, six.binary_type):
                logs = logs.decode(encoding='UTF-8', errors="ignore")

            msg = '{0}{1}'.format(msg, logs)

        logger.error(msg)
885687
def _unicode(self):
        ''''''

        return u'\n'.join ([ u''.join(c) for c in self.w ])
1228881
def exception_to_unicode(e, traceback=False):
    
    message = '%s: %s' % (e.__class__.__name__, to_unicode(e))
    if traceback:
        from docido_sdk.toolbox import get_last_traceback
        traceback_only = get_last_traceback().split('\n')[:-2]
        message = '\n%s\n%s' % (to_unicode('\n'.join(traceback_only)), message)
    return message
531462
public
  static
  String getFacilityString(int syslogFacility) {
    switch(syslogFacility) {
    case LOG_KERN:      return "kern";
    case LOG_USER:      return "user";
    case LOG_MAIL:      return "mail";
    case LOG_DAEMON:    return "daemon";
    case LOG_AUTH:      return "auth";
    case LOG_SYSLOG:    return "syslog";
    case LOG_LPR:       return "lpr";
    case LOG_NEWS:      return "news";
    case LOG_UUCP:      return "uucp";
    case LOG_CRON:      return "cron";
    case LOG_AUTHPRIV:  return "authpriv";
    case LOG_FTP:       return "ftp";
    case LOG_LOCAL0:    return "local0";
    case LOG_LOCAL1:    return "local1";
    case LOG_LOCAL2:    return "local2";
    case LOG_LOCAL3:    return "local3";
    case LOG_LOCAL4:    return "local4";
    case LOG_LOCAL5:    return "local5";
    case LOG_LOCAL6:    return "local6";
    case LOG_LOCAL7:    return "local7";
    default:            return null;
    }
  }
551432
def get_user_log(self, language='da'):
        """"""
        payload = """<getUserLog1 xmlns="utcs" />
                     <getUserLog2 xmlns="utcs">0</getUserLog2>
                     <getUserLog3 xmlns="utcs">{language}</getUserLog3>
                     """.format(language=language)
        xdoc = self.connection.soap_action('/ws/ConfigurationService',
                                           'getUserLog', payload)
        if xdoc:
            base64data = xdoc.find('./SOAP-ENV:Body/ns1:getUserLog4/ns1:data',
                                   IHCSoapClient.ihcns).text
            if not base64data:
                return False
            return base64.b64decode(base64data).decode('UTF-8')
        return False
142189
def get_log(self, offset, count=10, callback=None):
        '''
        
        '''
        params = {'offset': offset, 'count': count}
        return self.execute_command('getLog', params, callback=callback)
1233823
def _get_unicode(data, force=False):
    """"""
    if isinstance(data, binary_type):
        return data.decode('utf-8')
    elif data is None:
        return ''
    elif force:
        if PY2:
            return unicode(data)
        else:
            return str(data)
    else:
        return data
1141408
private static String  GetCurrentChar( Context context) {
        if (context.ptr >= context.inputString.length())
            return "EOL";
        return "" + context.inputString.charAt(context.ptr);
    }
458689
def parse_log(log, url_pattern):
    
    hits = {}
    initial_timestamp = None

    def clean_timestamp(v):
        return ' '.join(v).strip('[]')
    for line in log:
        data = line.split()
        if not initial_timestamp:
            initial_timestamp = clean_timestamp(data[3:5])
        match = url_pattern.match(data[6])
        if match:
            ident_hash = '@'.join(match.groups())
            if ident_hash:
                hits[ident_hash] = hits.get(ident_hash, 0) + 1
    else:
        end_timestamp = clean_timestamp(data[3:5])
    return hits, initial_timestamp, end_timestamp
901965
def log_to_file(self, message):
        """"""

        with self.build_fs.open(self.log_file, 'a+') as f:
            f.write(unicode(message + '\n'))
177489
def handle_log_entry(self, m):
        ''''''
        if m.time_utc == 0:
            tstring = ''
        else:
            tstring = time.ctime(m.time_utc)
        self.entries[m.id] = m
        print("Log %u  numLogs %u lastLog %u size %u %s" % (m.id, m.num_logs, m.last_log_num, m.size, tstring))
1223358
def parse_logs(self, f):
        """"""
        data = {}
        for l in f.splitlines():
            # catch empty lines
            if len(l) == 0:
                continue
            s = l.split("\t")
            data_ = []
            # catch lines with descriptive content: "Of pairs used:"
            for i in s[1:]:
                if len(i) == 0:
                    continue
                try:
                    i.replace('(', '')
                    i.replace(')', '')
                    i.replace(',', '')

                    data_.append(float(i))
                except ValueError:
                    data_.append(i)
            if len(data_) == 0:
                continue
            if s[0].startswith('short range'):
                s[0] = 'short range'
            elif s[0].startswith('same fragment'):
                s[0] = 'same fragment'
            s[0] = s[0].capitalize()
            data[s[0]] = data_
        return data
426756
private String getMessageI18N(LogRecord record) {
        String message = record.getMessage();

        if (message == null) {
            return null;
        }

        ResourceBundle bundle = record.getResourceBundle();
        if (bundle != null) {
            try {
                message = bundle.getString(message);
            } catch (MissingResourceException e) {
            }
        }
        Object[] params = record.getParameters();
        // avoid formatting when there are no or 0 parameters. see also
        // http://jira.qos.ch/browse/SLF4J-203
        if (params != null && params.length > 0) {
            try {
                message = MessageFormat.format(message, params);
            } catch (IllegalArgumentException e) {
                // default to the same behavior as in java.util.logging.Formatter.formatMessage(LogRecord)
                // see also http://jira.qos.ch/browse/SLF4J-337
                return message;
            }
        }
        return message;
    }
1060936
def getCustomLogger(name, logLevel, logFormat='%(asctime)s %(levelname)-9s:%(name)s:%(module)s:%(funcName)s: %(message)s'):
  '''
  
  '''
  assert isinstance(logFormat, basestring), ("logFormat must be a string but is %r" % logFormat)
  assert isinstance(logLevel, basestring), ("logLevel must be a string but is %r" % logLevel)
  assert isinstance(name, basestring), ("name must be a string but is %r" % name)

  validLogLevels = ['CRITICAL', 'DEBUG', 'ERROR', 'INFO', 'WARNING']

  if not logLevel:
    logLevel = 'DEBUG'

  # If they don't specify a valid log level, err on the side of verbosity
  if logLevel.upper() not in validLogLevels:
    logLevel = 'DEBUG'

  numericLevel = getattr(logging, logLevel.upper(), None)
  if not isinstance(numericLevel, int):
    raise ValueError("Invalid log level: %s" % logLevel)

  logging.basicConfig(level=numericLevel, format=logFormat)
  logger = logging.getLogger(name)
  return logger
215372
def _get_encoding(self):
        """"""
        enco = 'utf-8'

        #  Currently only cp1252 is allowed?
        if WIN:
            import ctypes
            codepage = to_text_string(ctypes.cdll.kernel32.GetACP())
            # import locale
            # locale.getpreferredencoding()  # Differences?
            enco = 'cp' + codepage
        return enco
792485
def get_unicodedata():
    """"""

    import unicodedata

    fail = False
    uver = unicodedata.unidata_version
    path = os.path.join(os.path.dirname(__file__), 'tools')
    fp, pathname, desc = imp.find_module('unidatadownload', [path])
    try:
        unidatadownload = imp.load_module('unidatadownload', fp, pathname, desc)
        unidatadownload.get_unicodedata(uver, no_zip=True)
    except Exception:
        print(traceback.format_exc())
        fail = True
    finally:
        fp.close()

    assert not fail, "Failed to obtain unicodedata!"
    return uver