@Override public String getSourceClassName() { if (!this.resolved) { resolve(); } return super.getSourceClassName(); }
public String getSourceClassName() { if (! resolved) { resolve(); } return super.getSourceClassName(); }
/** * Partially formats a log record. * @return date, source, level, message+thrown * @see SimpleFormatter#format(LogRecord) */ private static String[] logRecordPreformat(LogRecord r) { String source; if (r.getSourceClassName() == null) { source = r.getLoggerName(); } else { if (r.getSourceMethodName() == null) { source = r.getSourceClassName(); } else { source = r.getSourceClassName() + " " + r.getSourceMethodName(); } } String message = new SimpleFormatter().formatMessage(r) + "\n"; Throwable x = r.getThrown(); return new String[] { String.format("%1$tb %1$td, %1$tY %1$tl:%1$tM:%1$tS %1$Tp", new Date(r.getMillis())), source, r.getLevel().getLocalizedName(), x == null ? message : message + printThrowable(x) + "\n" }; }
@Override public synchronized String format(LogRecord record) { StringBuilder sb = new StringBuilder(); sb.append(sdf.format(new Date(record.getMillis()))).append(" "); sb.append(record.getLevel()).append(" "); sb.append("["); sb.append(record.getSourceClassName()).append(".").append(record.getSourceMethodName()); sb.append("] "); sb.append(record.getMessage()); sb.append(System.getProperty("line.separator")); return sb.toString(); } }
@Override public synchronized String format(LogRecord record) { this.buffer.setLength(0); this.date.setTime(record.getMillis()); this.position.setBeginIndex(0); this.formatter.format(this.date, this.buffer, this.position); this.buffer.append(' '); if (record.getSourceClassName() != null) { this.buffer.append(record.getSourceClassName()); } else { this.buffer.append(record.getLoggerName()); } this.buffer.append(' '); this.buffer.append(formatMessage(record)); this.buffer.append(System.getProperty("line.separator")); if (record.getThrown() != null) { try { StringWriter writer = new StringWriter(); PrintWriter printer = new PrintWriter(writer); record.getThrown().printStackTrace(printer); writer.close(); this.buffer.append(writer.toString()); } catch (Exception e) { this.buffer.append("Failed to get stack trace: " + e.getMessage()); } } return this.buffer.toString(); } }
public String format(LogRecord record) { StringBuilder sb = new StringBuilder(); sb.append(record.getLevel().getLocalizedName()); sb.append(" ["); final String logger = record.getSourceClassName(); sb.append(logger.substring(logger.lastIndexOf('.') + 1)); sb.append("]: "); sb.append(record.getMessage()); sb.append(LINE_SEPARATOR); if (record.getThrown() != null) { try (StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw)) { record.getThrown().printStackTrace(pw); sb.append(sw.toString()); } catch (IOException e) { // ignore } } return sb.toString(); } }
@Override @SuppressWarnings("ThrowableResultOfMethodCallIgnored") public String format(final LogRecord record) { final StringBuilder sb = new StringBuilder(); String source = record.getSourceClassName() == null ? record.getLoggerName() : record.getSourceClassName(); source = source.substring(source.length() - 15) + "." + (record.getSourceMethodName() == null ? "" : record.getSourceMethodName()); final Object[] arguments = new Object[6]; arguments[0] = source; arguments[1] = record.getLevel(); arguments[2] = Thread.currentThread().getName(); arguments[3] = new Date(record.getMillis()); arguments[4] = record.getMessage(); sb.append(FORMAT.format(arguments)); if (record.getThrown() != null) { try { final StringWriter sw = new StringWriter(); final PrintWriter pw = new PrintWriter(sw); //CHECKSTYLE:OFF record.getThrown().printStackTrace(pw); //CHECKSTYLE:ON pw.close(); sb.append(sw.toString()); } catch (Exception ex) { LOG.error(ex.getMessage(), ex); } } sb.append("\n"); return sb.toString(); }
Date dat = new Date(record.getMillis()); StringBuilder source = new StringBuilder(); if(record.getSourceClassName() != null) { source.append(record.getSourceClassName()); if(record.getSourceMethodName() != null) { source.append(' ').append(record.getSourceMethodName()); record.getSourceClassName(), //%7 className(record.getSourceClassName()),//%9
clazz = Class.forName(record.getSourceClassName()).getSimpleName(); } catch (ClassNotFoundException ex){
dat.setTime(record.getMillis()); String source; if (record.getSourceClassName() != null) { source = record.getSourceClassName(); if (record.getSourceMethodName() != null) { source += " " + record.getSourceMethodName();
sb.append(MessageFormat.format("{0, date} {0, time} ", new Object[] { new Date(r.getMillis()) })); sb.append(r.getSourceClassName()).append(" "); sb.append(r.getSourceMethodName()).append(System.lineSeparator()); sb.append(r.getLevel().getName()).append(": ");
sb.append(text); sb.append(" "); if (record.getSourceClassName() != null) { sb.append(record.getSourceClassName()); } else { sb.append(record.getLoggerName());
buffer.append(record.getThreadID()); buffer.append(' '); if (record.getSourceClassName() != null) { buffer.append(record.getSourceClassName()); } else { buffer.append(record.getLoggerName());
if (record.getSourceClassName() != null) { sb.append(record.getSourceClassName()); } else { sb.append(record.getLoggerName());
if (r.getSourceClassName() != null) { append(sb, 1, "class", r.getSourceClassName());
writer.write(SUFFIX); if (record.getSourceClassName() != null) { writer.write(record.getSourceClassName());
@Override public void publish(LogRecord record) { // check that the log record should be logged if (!isLoggable(record)) { return; } // HACK warning: this logger doesn't work like normal loggers; the log calls are issued // from another class instead of by itself, so it can't be configured off like normal // loggers. We have to check the source class name instead. if ("io.netty.handler.codec.http2.Http2FrameLogger".equals(record.getSourceClassName())) { return; } LogEntry logEntry; try { logEntry = logEntryFor(record); } catch (Exception ex) { getErrorManager().error(null, ex, ErrorManager.FORMAT_FAILURE); return; } if (logEntry != null) { try { getLogging().write(ImmutableList.of(logEntry), defaultWriteOptions); } catch (Exception ex) { getErrorManager().error(null, ex, ErrorManager.WRITE_FAILURE); } } }
sb.append(record.getSourceClassName()); sb.append('.'); sb.append(record.getSourceMethodName());
/** * Formats the source from the given log record. * * @param record the record. * @return the formatted source of the log record. * @throws NullPointerException if the given record is null. */ public String formatSource(final LogRecord record) { String source = record.getSourceClassName(); if (source != null) { if (record.getSourceMethodName() != null) { source = simpleClassName(source) + " " + record.getSourceMethodName(); } else { source = simpleClassName(source); } } else { source = simpleClassName(record.getLoggerName()); } return source; }
/** * Formats the source from the given log record. * * @param record the record. * @return the formatted source of the log record. * @throws NullPointerException if the given record is null. */ public String formatSource(final LogRecord record) { String source = record.getSourceClassName(); if (source != null) { if (record.getSourceMethodName() != null) { source = simpleClassName(source) + " " + record.getSourceMethodName(); } else { source = simpleClassName(source); } } else { source = simpleClassName(record.getLoggerName()); } return source; }