Returns a formatted log line
483436
def format(self, filename, line, timestamp, **kwargs):
        """"""
        line = unicode(line.encode("utf-8"), "utf-8", errors="ignore")
        formatter = self._beaver_config.get_field('format', filename)
        if formatter not in self._formatters:
            formatter = self._default_formatter

        data = {
            self._fields.get('type'): kwargs.get('type'),
            self._fields.get('tags'): kwargs.get('tags'),
            '@timestamp': timestamp,
            self._fields.get('host'): self._current_host,
            self._fields.get('file'): filename,
            self._fields.get('message'): line
        }

        if self._logstash_version == 0:
            data['@source'] = 'file://{0}'.format(filename)
            data['@fields'] = kwargs.get('fields')
        else:
            data['@version'] = self._logstash_version
            fields = kwargs.get('fields')
            for key in fields:
                data[key] = fields.get(key)

        return self._formatters[formatter](data)
332931
def read(self, log_file):
        
        if os.path.isdir(os.path.dirname(log_file)) and os.path.isfile(log_file):
            with open(log_file, 'r') as LogFile:
                data = LogFile.readlines()
                data = "".join(line for line in data)
        else:
            data = ''
        return data
590573
def parse(logfile, time_format):
  ""

  records = [server.record_from_txt(line, only_elapsed=True,
    time_format=time_format) for line in sys.stdin.readlines()]

  # TODO: make this code better.
  def output(summary):
    width = max([len(p[0]) for p in summary]) + 3
    print '\n'.join([
      "%s%s%s" % (p[0], ' ' * (width - len(p[0])),
        colored(minutes_to_txt(p[1]), 'red')) for p in summary])

  output(server.summarize(records))
1332203
def _parse_logline_timestamp(t):
    
    date, time = t.split(' ')
    month, day = date.split('-')
    h, m, s = time.split(':')
    s, ms = s.split('.')
    return (month, day, h, m, s, ms)
1069669
private String formatLogString(Diagnostics diagnostics) {

    StringBuilder sb = new StringBuilder();
    sb.append(LOG_STRING_PREFIX).append(SEPARATOR);
    if (null != diagnostics.getId()) {
      sb.append("id=").append(diagnostics.getId()).append(SEPARATOR);
    }
    if (null != diagnostics.getTimestamp()) {
      sb.append("date=").append(formatter.format(new DateTime(diagnostics.getTimestamp()).toDate())).append(SEPARATOR);
    }
    if (null != diagnostics.getTag()) {
      sb.append("tag=").append(diagnostics.getTag()).append(SEPARATOR);
    }
    if (null != diagnostics.getInfo()) {
      sb.append("info=").append(diagnostics.getInfo()).append(SEPARATOR);
    }

    return sb.toString();
  }
914062
def format(self, record: logging.LogRecord) -> str:
        

        # message = super().format(record)
        super().format(record)
        # Since fmt does not contain asctime, the Formatter.format()
        # will not write asctime (since its usesTime()) function will be
        # false. Therefore:
        record.asctime = self.formatTime(record, self.datefmt)
        bg_col = self.log_background_colors[record.levelno]
        msg = escape(record.getMessage())
        # escape() won't replace \n but will replace & etc.
        if self.replace_nl_with_br:
            msg = msg.replace("\n", "<br>")
        html = (
            '<span style="color:#008B8B">{time}.{ms:03d} {name}:{lvname}: '
            '</span><span style="color:{color}{bg}">{msg}</font>{br}'.format(
                time=record.asctime,
                ms=int(record.msecs),
                name=record.name,
                lvname=record.levelname,
                color=self.log_colors[record.levelno],
                msg=msg,
                bg=";background-color:{}".format(bg_col) if bg_col else "",
                br="<br>" if self.append_br else "",
            )
        )
        # print("record.__dict__: {}".format(record.__dict__))
        # print("html: {}".format(html))
        return html
37134
def format_log(ret):
    '''
    
    '''
    msg = ''
    if isinstance(ret, dict):
        # Looks like the ret may be a valid state return
        if 'changes' in ret:
            # Yep, looks like a valid state return
            chg = ret['changes']
            if not chg:
                if ret['comment']:
                    msg = ret['comment']
                else:
                    msg = 'No changes made for {0[name]}'.format(ret)
            elif isinstance(chg, dict):
                if 'diff' in chg:
                    if isinstance(chg['diff'], six.string_types):
                        msg = 'File changed:\n{0}'.format(chg['diff'])
                if all([isinstance(x, dict) for x in six.itervalues(chg)]):
                    if all([('old' in x and 'new' in x)
                            for x in six.itervalues(chg)]):
                        msg = 'Made the following changes:\n'
                        for pkg in chg:
                            old = chg[pkg]['old']
                            if not old and old not in (False, None):
                                old = 'absent'
                            new = chg[pkg]['new']
                            if not new and new not in (False, None):
                                new = 'absent'
                            # This must be able to handle unicode as some package names contain
                            # non-ascii characters like "Français" or "Español". See Issue #33605.
                            msg += '\'{0}\' changed from \'{1}\' to \'{2}\'\n'.format(pkg, old, new)
            if not msg:
                msg = six.text_type(ret['changes'])
            if ret['result'] is True or ret['result'] is None:
                log.info(msg)
            else:
                log.error(msg)
    else:
        # catch unhandled data
        log.info(six.text_type(ret))
83678
static function format_logline( PLUGError $Err ){
		if( PLUG::is_compiled() ){
			return sprintf(
				'%s: %s: %s', 
				basename(self::arg(0)), 
				$Err->getTypeString(), 
				$Err->getMessage()
			);
		}
		else {
			return sprintf(
				'%s: %s: %s in %s#%u', 
				basename(self::arg(0)), 
				$Err->getTypeString(), 
				$Err->getMessage(), 
				basename($Err->getFile()), 
				$Err->getLine()
			);
		}
	}
1303913
def as_log_output(self):
        
        elem = self.to_element()
        for attrname in self.sensitive_attributes:
            for sensitive_el in elem.iter(attrname):
                sensitive_el.text = 'XXXXXXXXXXXXXXXX'
        return ElementTreeBuilder.tostring(elem, encoding='UTF-8')
1030775
public String format(LogRecord record) {
        StringBuffer sb = new StringBuffer();
        String message = formatMessage(record);
        sb.append(message);
        sb.append(lineSeparator);
        if (record.getThrown() != null) {
            try {
                StringWriter sw = new StringWriter();
                PrintWriter pw = new PrintWriter(sw);
                record.getThrown().printStackTrace(pw);
                pw.close();
            sb.append(sw.toString());
            } catch (Exception ex) {
            	if (record.getThrown().getCause() != null){
					sb.append(record.getThrown().getCause().getLocalizedMessage());
            	}else{
					sb.append(record.getThrown().getLocalizedMessage());
            	}
            	
            }
        }
        return sb.toString();
    }
68099
def format(self, record):
        """"""
        # NOTE(sdague): default the fancier formating params
        # to an empty string so we don't throw an exception if
        # they get used
        for key in ('instance', 'color'):
            if key not in record.__dict__:
                record.__dict__[key] = ''

        if record.__dict__.get('request_id', None):
            self._fmt = CONF.logging_context_format_string
        else:
            self._fmt = CONF.logging_default_format_string

        if (record.levelno == logging.DEBUG and
                CONF.logging_debug_format_suffix):
            self._fmt += " " + CONF.logging_debug_format_suffix

        # Cache this on the record, Logger will respect our formated copy
        if record.exc_info:
            record.exc_text = self.formatException(record.exc_info, record)
        return logging.Formatter.format(self, record)
1182366
public synchronized String format(LogRecord record) {
        text.setLength(LOG_MSG_PREFIX.length());

        // date
        ((Date)args[0]).setTime(record.getMillis());
        text.append('|');
        formatter.format(args, text, null);

        // logging level
        text.append('|').append(record.getLevel().getLocalizedName());

        // thread id
        text.append("|t-").append(record.getThreadID());

        // source
        text.append('|');
        if (record.getSourceClassName() != null) {
            text.append(record.getSourceClassName().substring(record.getSourceClassName().lastIndexOf('.')+1));
        } else {
            text.append(record.getLoggerName());
        }
        if (record.getSourceMethodName() != null) {
            text.append('[');
            text.append(record.getSourceMethodName().substring(record.getSourceMethodName().lastIndexOf('.')+1));
            text.append(']');
        }

        // message
        text.append(' ').append(formatMessage(record)).append(LINE_SEPARATOR);

        if (record.getThrown() != null) {
            StackTraceElement[] traces = record.getThrown().getStackTrace();
            for (int i = 0; i < traces.length; ++i) {
                text.append(traces[i].toString()).append(LINE_SEPARATOR);
            }
        }

        return text.toString();
    }
530538
def format(self, record: logging.LogRecord) -> str:
        
        if platform.system() != 'Linux':  # Avoid funny logs on Windows & MacOS
            return super().format(record)

        record.msg = (
            self.STYLE[record.levelname] + record.msg + self.STYLE['END'])
        record.levelname = (
            self.STYLE['LEVEL'] + record.levelname + self.STYLE['END'])
        return super().format(record)
142189
def get_log(self, offset, count=10, callback=None):
        '''
        
        '''
        params = {'offset': offset, 'count': count}
        return self.execute_command('getLog', params, callback=callback)
658684
def get_logger(name=None, format_string=None):
    
    logging.captureWarnings(True)
    log = logging.getLogger(name)

    # Bind custom method to instance.
    # Source: https://stackoverflow.com/a/2982
    log.set_debug_level = _set_debug_level.__get__(log)
    log.set_debug_level(0)

    if not format_string:
        format_string = '[%(module)s]\t%(levelname)s\t%(message)s'

    # Setting up log formats
    log.handlers = []
    handler = logging.StreamHandler(sys.stderr)
    handler.setFormatter(
        logging.Formatter(format_string),
    )
    log.addHandler(handler)

    return log
331486
def get_log(self, request, response):
        
        return {
            'method': request.method,
            'path': request.get_full_path(),
            'code': response.status_code,
            'time': time.time(),
        }
836082
static function apacheLogLine( $format = 'common', $size='-', $httpReturn = '200' )
    {
        switch ( $format )
        {
            /// LogFormat "%h %l %u %t \"%r\" % >s %b \"%{Referer}i\" \"%{User-Agent}i\"
            /// @todo add values for %l (remote logname), %u (remote user)
            case 'combined':
                return $_SERVER["REMOTE_ADDR"] . ' - - [' . date( 'd/M/Y:H:i:s O' ) . '] "' . $_SERVER["REQUEST_METHOD"] . ' ' . $_SERVER["REQUEST_URI"]. ' ' . $_SERVER["SERVER_PROTOCOL"] . '" 200 ' . $size . ' "' . @$_SERVER["HTTP_REFERER"] . '" "' . @$_SERVER["HTTP_USER_AGENT"] . '"';
            case 'common':
            default:
                return $_SERVER["REMOTE_ADDR"] . ' - - [' . date( 'd/M/Y:H:i:s O' ) . '] "' . $_SERVER["REQUEST_METHOD"] . ' ' . $_SERVER["REQUEST_URI"]. ' ' . $_SERVER["SERVER_PROTOCOL"] . '" 200 ' . $size;
        }
    }