@Override public void log(Marker marker, String callerFQCN, int level, String msg, Object[] argArray, Throwable t) { Level log4jLevel; switch (level) { case LocationAwareLogger.TRACE_INT: log4jLevel = traceCapable ? Level.TRACE : Level.DEBUG; break; case LocationAwareLogger.DEBUG_INT: log4jLevel = Level.DEBUG; break; case LocationAwareLogger.INFO_INT: log4jLevel = Level.INFO; break; case LocationAwareLogger.WARN_INT: log4jLevel = Level.WARN; break; case LocationAwareLogger.ERROR_INT: log4jLevel = Level.ERROR; break; default: throw new IllegalStateException("Level number " + level + " is not recognized."); } logger.log(callerFQCN, log4jLevel, msg, t); }
private Level slf4jLevelIntToJULLevel(int slf4jLevelInt) { Level julLevel; switch (slf4jLevelInt) { case LocationAwareLogger.TRACE_INT: julLevel = Level.FINEST; break; case LocationAwareLogger.DEBUG_INT: julLevel = Level.FINE; break; case LocationAwareLogger.INFO_INT: julLevel = Level.INFO; break; case LocationAwareLogger.WARN_INT: julLevel = Level.WARNING; break; case LocationAwareLogger.ERROR_INT: julLevel = Level.SEVERE; break; default: throw new IllegalStateException("Level number " + slf4jLevelInt + " is not recognized."); } return julLevel; }
@Override public void log(String fqcn, Level level, Throwable t, String format, Object... arguments) { int level_int; switch (level) { case TRACE: level_int = LocationAwareLogger.TRACE_INT; break; case DEBUG: level_int = LocationAwareLogger.DEBUG_INT; break; case INFO: level_int = LocationAwareLogger.INFO_INT; break; case WARN: level_int = LocationAwareLogger.WARN_INT; break; case ERROR: level_int = LocationAwareLogger.ERROR_INT; break; default: throw new Error(StringKit.format("Can not identify level: {}", level)); } this.locationAwareLog(fqcn, level_int, t, format, arguments); }
/** * Convert this level instance to an integer value defined in the * {@link LocationAwareLogger} interface. * * @param level The level to convert to LocationAwareLogger integer * @return int An integer corresponding to this level as defined in LocationAwareLogger * @since 1.0.1 */ public static int toLocationAwareLoggerInteger(Level level) { if (level == null) throw new IllegalArgumentException("null level parameter is not admitted"); switch (level.toInt()) { case Level.TRACE_INT: return LocationAwareLogger.TRACE_INT; case Level.DEBUG_INT: return LocationAwareLogger.DEBUG_INT; case Level.INFO_INT: return LocationAwareLogger.INFO_INT; case Level.WARN_INT: return LocationAwareLogger.WARN_INT; case Level.ERROR_INT: return LocationAwareLogger.ERROR_INT; default: throw new IllegalArgumentException(level + " not a valid level value"); } }
/** * Convert one of the integer values defined in {@link LocationAwareLogger} * interface to an instance of this class, i.e. a Level. * * @param levelInt An integer value representing a level as defined in LocationAwareLogger * @return an instance of this class, i.e. a Level. * @since 1.0.1 */ public static Level fromLocationAwareLoggerInteger(int levelInt) { Level level; switch (levelInt) { case LocationAwareLogger.TRACE_INT: level = TRACE; break; case LocationAwareLogger.DEBUG_INT: level = DEBUG; break; case LocationAwareLogger.INFO_INT: level = INFO; break; case LocationAwareLogger.WARN_INT: level = WARN; break; case LocationAwareLogger.ERROR_INT: level = ERROR; break; default: throw new IllegalArgumentException(levelInt + " not a valid level value"); } return level; }
/** * Publish a LogRecord. * <p/> * The logging request was made initially to a Logger object, which * initialized the LogRecord and forwarded it here. * <p/> * This handler ignores the Level attached to the LogRecord, as SLF4J cares * about discarding log statements. * * @param record Description of the log event. A null record is silently ignored * and is not published. */ public void publish(LogRecord record) { // Silently ignore null records. if (record == null) { return; } Logger slf4jLogger = getSLF4JLogger(record); String message = record.getMessage(); // can be null! // this is a check to avoid calling the underlying logging system // with a null message. While it is legitimate to invoke j.u.l. with // a null message, other logging frameworks do not support this. // see also http://bugzilla.slf4j.org/show_bug.cgi?id=108 if (message == null) { message = ""; } if (slf4jLogger instanceof LocationAwareLogger) { callLocationAwareLogger((LocationAwareLogger) slf4jLogger, record); } else { callPlainSLF4JLogger(slf4jLogger, record); } }
protected void callLocationAwareLogger(LocationAwareLogger lal, LogRecord record) { int julLevelValue = record.getLevel().intValue(); int slf4jLevel; if (julLevelValue <= TRACE_LEVEL_THRESHOLD) { slf4jLevel = LocationAwareLogger.TRACE_INT; } else if (julLevelValue <= DEBUG_LEVEL_THRESHOLD) { slf4jLevel = LocationAwareLogger.DEBUG_INT; } else if (julLevelValue <= INFO_LEVEL_THRESHOLD) { slf4jLevel = LocationAwareLogger.INFO_INT; } else if (julLevelValue <= WARN_LEVEL_THRESHOLD) { slf4jLevel = LocationAwareLogger.WARN_INT; } else { slf4jLevel = LocationAwareLogger.ERROR_INT; } String i18nMessage = getMessageI18N(record); lal.log(null, FQCN, slf4jLevel, i18nMessage, null, record.getThrown()); }
void differentiatedLog(Marker marker, String fqcn, int level, Object message, Throwable t) { String m = convertToString(message); if (locationAwareLogger != null) { locationAwareLogger.log(marker, fqcn, level, m, null, t); } else { switch (level) { case LocationAwareLogger.TRACE_INT: slf4jLogger.trace(marker, m); break; case LocationAwareLogger.DEBUG_INT: slf4jLogger.debug(marker, m); break; case LocationAwareLogger.INFO_INT: slf4jLogger.info(marker, m); break; case LocationAwareLogger.WARN_INT: slf4jLogger.warn(marker, m); break; case LocationAwareLogger.ERROR_INT: slf4jLogger.error(marker, m); break; } } }
public LambdaLoggerLocationAwareImpl(LocationAwareLogger underlyingLogger) { if (underlyingLogger == null) { throw new IllegalArgumentException("underlyingLogger must not be null."); } this.underlyingLogger = underlyingLogger; }
@Override public LambdaLogger buildLambdaLogger(Logger underlyingLogger) { if (underlyingLogger instanceof LocationAwareLogger) { return new LambdaLoggerLocationAwareImpl((LocationAwareLogger) underlyingLogger); } return new LambdaLoggerPlainImpl(underlyingLogger); }
public Slf4jESLogger(String prefix, Logger logger) { super(prefix); this.logger = logger; if (logger instanceof LocationAwareLogger) { lALogger = (LocationAwareLogger) logger; } else { lALogger = null; } }
@Override protected void internalTrace(String msg) { if (lALogger != null) { lALogger.log(null, FQCN, LocationAwareLogger.TRACE_INT, msg, null, null); } else { logger.trace(msg); } }
@Override protected void internalTrace(String msg, Throwable cause) { if (lALogger != null) { lALogger.log(null, FQCN, LocationAwareLogger.TRACE_INT, msg, null, cause); } else { logger.trace(msg); } }
@Override protected void internalDebug(String msg) { if (lALogger != null) { lALogger.log(null, FQCN, LocationAwareLogger.DEBUG_INT, msg, null, null); } else { logger.debug(msg); } }
@Override protected void internalDebug(String msg, Throwable cause) { if (lALogger != null) { lALogger.log(null, FQCN, LocationAwareLogger.DEBUG_INT, msg, null, cause); } else { logger.debug(msg); } }
@Override protected void internalInfo(String msg) { if (lALogger != null) { lALogger.log(null, FQCN, LocationAwareLogger.INFO_INT, msg, null, null); } else { logger.info(msg); } }
@Override protected void internalInfo(String msg, Throwable cause) { if (lALogger != null) { lALogger.log(null, FQCN, LocationAwareLogger.INFO_INT, msg, null, cause); } else { logger.info(msg, cause); } }
@Override protected void internalWarn(String msg) { if (lALogger != null) { lALogger.log(null, FQCN, LocationAwareLogger.WARN_INT, msg, null, null); } else { logger.warn(msg); } }
@Override protected void internalWarn(String msg, Throwable cause) { if (lALogger != null) { lALogger.log(null, FQCN, LocationAwareLogger.WARN_INT, msg, null, cause); } else { logger.warn(msg); } }
@Override protected void internalError(String msg) { if (lALogger != null) { lALogger.log(null, FQCN, LocationAwareLogger.ERROR_INT, msg, null, null); } else { logger.error(msg); } }
@Override protected void internalError(String msg, Throwable cause) { if (lALogger != null) { lALogger.log(null, FQCN, LocationAwareLogger.ERROR_INT, msg, null, cause); } else { logger.error(msg); } }
public void info(String message, Throwable t) { if (log instanceof LocationAwareLogger) { ((LocationAwareLogger) log).log(null, FQCN, LocationAwareLogger.INFO_INT, message, null, t); } else { log.info(message, t); } }
public void debug(String message, Throwable t) { if (log instanceof LocationAwareLogger) { ((LocationAwareLogger) log).log(null, FQCN, LocationAwareLogger.DEBUG_INT, message, null, t); } else { log.debug(message, t); } }
public void warn(String message, Throwable t) { if (log instanceof LocationAwareLogger) { ((LocationAwareLogger) log).log(null, FQCN, LocationAwareLogger.WARN_INT, message, null, t); } else { log.warn(message); } }
public void error(String message, Throwable t) { if (log instanceof LocationAwareLogger) { ((LocationAwareLogger) log).log(null, FQCN, LocationAwareLogger.ERROR_INT, message, null, t); } else { log.error(message); } }
@Override public void trace(String message, Throwable t) { if (log instanceof LocationAwareLogger) { ((LocationAwareLogger) log).log(null, FQCN, LocationAwareLogger.TRACE_INT, message, null, t); } else { log.error(message); } }
/** * Printing method with support for location information. * * @param marker The marker to be used for this event, may be null. * @param callerFQCN The fully qualified class name of the <b>logger instance</b>, typically the logger * class, logger bridge or a logger wrapper. * @param level One of the level integers defined in this interface * @param message The message for the log event * @param t Throwable associated with the log event, may be null. */ @Override public void log(Marker marker, String callerFQCN, int level, String message, Object[] argArray, Throwable t) { Level log4jLevel; switch (level) { case LocationAwareLogger.TRACE_INT: log4jLevel = traceCapable ? Level.TRACE : Level.DEBUG; break; case LocationAwareLogger.DEBUG_INT: log4jLevel = Level.DEBUG; break; case LocationAwareLogger.INFO_INT: log4jLevel = Level.INFO; break; case LocationAwareLogger.WARN_INT: log4jLevel = Level.WARN; break; case LocationAwareLogger.ERROR_INT: log4jLevel = Level.ERROR; break; default: throw new IllegalStateException("Level number " + level + " is not recognized."); } logger.log(callerFQCN, log4jLevel, message, t); }
public void debug(String msg) { if (isLocationAwareLogger) { ((LocationAwareLogger) slf4jLogger).log(null, FQCN, LocationAwareLogger.DEBUG_INT, msg, null, null); } else { slf4jLogger.debug(msg); } }
public void debug(String msg, Throwable t) { if (isLocationAwareLogger) { ((LocationAwareLogger) slf4jLogger).log(null, FQCN, LocationAwareLogger.DEBUG_INT, msg, null, t); } else { slf4jLogger.debug(msg, t); } }
public void error(String msg) { if (isLocationAwareLogger) { ((LocationAwareLogger) slf4jLogger).log(null, FQCN, LocationAwareLogger.ERROR_INT, msg, null, null); } else { slf4jLogger.error(msg); } }
public void error(String msg, Throwable t) { if (isLocationAwareLogger) { ((LocationAwareLogger) slf4jLogger).log(null, FQCN, LocationAwareLogger.ERROR_INT, msg, null, t); } else { slf4jLogger.error(msg, t); } }
public void info(String msg) { if (isLocationAwareLogger) { ((LocationAwareLogger) slf4jLogger).log(null, FQCN, LocationAwareLogger.INFO_INT, msg, null, null); } else { slf4jLogger.info(msg); } }
public void info(String msg, Throwable t) { if (isLocationAwareLogger) { ((LocationAwareLogger) slf4jLogger).log(null, FQCN, LocationAwareLogger.INFO_INT, msg, null, t); } else { slf4jLogger.error(msg, t); } }
public void trace(String msg) { if (isLocationAwareLogger) { ((LocationAwareLogger) slf4jLogger).log(null, FQCN, LocationAwareLogger.TRACE_INT, msg, null, null); } else { slf4jLogger.trace(msg); } }
public void trace(String msg, Throwable t) { if (isLocationAwareLogger) { ((LocationAwareLogger) slf4jLogger).log(null, FQCN, LocationAwareLogger.TRACE_INT, msg, null, t); } else { slf4jLogger.trace(msg, t); } }
public void warn(String msg) { if (isLocationAwareLogger) { ((LocationAwareLogger) slf4jLogger).log(null, FQCN, LocationAwareLogger.WARN_INT, msg, null, null); } else { slf4jLogger.error(msg); } }
public void warn(String msg, Throwable t) { if (isLocationAwareLogger) { ((LocationAwareLogger) slf4jLogger).log(null, FQCN, LocationAwareLogger.WARN_INT, msg, null, t); } else { slf4jLogger.error(msg, t); } }