@Override public String getSourceMethodName() { if (!this.resolved) { resolve(); } return super.getSourceMethodName(); }
public String getSourceMethodName() { if (! resolved) { resolve(); } return super.getSourceMethodName(); }
@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(); } }
/** * 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 @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(); }
if (record.getSourceClassName() != null) { source = record.getSourceClassName(); if (record.getSourceMethodName() != null) { source += " " + record.getSourceMethodName();
if(record.getSourceClassName() != null) { source.append(record.getSourceClassName()); if(record.getSourceMethodName() != null) { source.append(' ').append(record.getSourceMethodName()); record.getSourceMethodName(), //%8
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(formatMessage(r)).append(System.lineSeparator());
sb.append(record.getLoggerName()); if (record.getSourceMethodName() != null) { sb.append(" "); sb.append(record.getSourceMethodName());
if (record.getSourceMethodName() != null) { sb.append(" "); sb.append(record.getSourceMethodName());
String methodName = record.getSourceMethodName(); methodName = (methodName == null || methodName.length() <= 0)? "-": methodName;
append(sb, 1, "class", r.getSourceClassName()); if (r.getSourceMethodName() != null) { append(sb, 1, "method", r.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; }
sb.append(record.getSourceClassName()); sb.append('.'); sb.append(record.getSourceMethodName());
public Object answer(InvocationOnMock invocation) { Object[] arguments = invocation.getArguments(); LogRecord logRecord = (LogRecord) arguments[0]; if (logRecord.getLevel() == Level.WARNING && !logRecord.getSourceMethodName().equals("finalize")) { warningsCount++; } return null; } })
/** * Accumulates log records which will be used to produce the final output. * The output is generated using the {@link #getTail} method which also * resets this formatter back to its original state. * * @param record the record to store. * @return an empty string. * @throws NullPointerException if the given record is null. */ @Override public String format(final LogRecord record) { if (record == null) { throw new NullPointerException(); } boolean accepted; do { final LogRecord peek = peek(); //The self compare of the first record acts like a type check. LogRecord update = apply(peek != null ? peek : record, record); if (peek != update) { //Not identical. update.getSourceMethodName(); //Infer caller, null check. accepted = acceptAndUpdate(peek, update); } else { accepted = accept(peek, record); } } while (!accepted); return ""; }
/** * Accumulates log records which will be used to produce the final output. * The output is generated using the {@link #getTail} method which also * resets this formatter back to its original state. * * @param record the record to store. * @return an empty string. * @throws NullPointerException if the given record is null. */ @Override public String format(final LogRecord record) { if (record == null) { throw new NullPointerException(); } boolean accepted; do { final LogRecord peek = peek(); //The self compare of the first record acts like a type check. LogRecord update = apply(peek != null ? peek : record, record); if (peek != update) { //Not identical. update.getSourceMethodName(); //Infer caller, null check. accepted = acceptAndUpdate(peek, update); } else { accepted = accept(peek, record); } } while (!accepted); return ""; }
try { if (isLoggable(record)) { record.getSourceMethodName(); //Infer caller. publish0(record);
try { if (isLoggable(record)) { record.getSourceMethodName(); //Infer caller. publish0(record);