/** * Determine if its log-able at this level within this class. */ public boolean isLoggable(final Level level) { return logImpl.isLoggable(clazz, level); }
protected void log(final Level level, final Throwable ex, final String message, final StackTraceElement[] locations) { final StackTraceElement caller = extract(locations, EXCLUDE_LIST); if (null != caller) { logImpl.log(clazz, caller, level, message, ex); } else { logImpl.log(clazz, (String)null, level, message, ex); } }
/** * Logs based on the parameters given. Uses the format parameter inside * {@link MessageFormat}. * * @param level * the logging level at which to write the message. * @param ex * [optional] exception stack trace to log. * @param format * [optional] create a message of a particular format. * @param args * [optional] parameters to the format string. */ public void log(final Level level, final Throwable ex, final String format, final Object... args) { if (isLoggable(level)) { String message = format; if (format != null && args != null) { // consider using thread local pattern to cache these for // performance the pattern will always may always changed. message = MessageFormat.format(format, args); } else if (format == null && ex != null) { message = ex.getLocalizedMessage(); } //To get the StackTrace is expensive. Extract the method name only if it's necessary!!! log(level, ex, message, logImpl.needToInferCaller(clazz, level) ? Thread.currentThread().getStackTrace() : null); } }
/** * Logs based on the parameters given. Uses the format parameter inside * {@link MessageFormat}. * * @param level * the logging level at which to write the message. * @param ex * [optional] exception stack trace to log. * @param format * [optional] create a message of a particular format. * @param args * [optional] parameters to the format string. */ public void log(final Level level, final Throwable ex, final String format, final Object... args) { if (isLoggable(level)) { String message = format; if (format != null && args != null) { // consider using thread local pattern to cache these for // performance the pattern will always may always changed. message = MessageFormat.format(format, args); } else if (format == null && ex != null) { message = ex.getLocalizedMessage(); } //To get the StackTrace is expensive. Extract the method name only if it's necessary!!! log(level, ex, message, logImpl.needToInferCaller(clazz, level) ? Thread.currentThread().getStackTrace() : null); } }
protected void log(final Level level, final Throwable ex, final String message, final StackTraceElement[] locations) { final StackTraceElement caller = extract(locations, EXCLUDE_LIST); if (null != caller) { logImpl.log(clazz, caller, level, message, ex); } else { logImpl.log(clazz, (String)null, level, message, ex); } }
/** * Determine if its log-able at this level within this class. */ public boolean isLoggable(final Level level) { return _logImpl.isLoggable(_clazz, level); }
/** * Lowest level logging method. * * @param clazz * Class that is being logged. * @param method * Method name that is being logged. * @param level * Logging level. * @param message * Message about the log. * @param ex * Exception to use process. */ public void log(final Class<?> clazz, final String method, final Log.Level level, final String message, final Throwable ex) { if (isLoggable(level)) { logImpl.log(clazz, method, level, message, ex); } }
/** * Determine if its log-able at this level within this class. */ public boolean isLoggable(final Level level) { return logImpl.isLoggable(clazz, level); }
/** * Lowest level logging method. * * @param clazz * Class that is being logged. * @param method * Method name that is being logged. * @param level * Logging level. * @param message * Message about the log. * @param ex * Exception to use process. */ public void log(final Class<?> clazz, final String method, final Log.Level level, final String message, final Throwable ex) { if (isLoggable(level)) { logImpl.log(clazz, method, level, message, ex); } }
@Test public void checkIsLogger() { LogSpi logSpi = new StdOutLogger(); for (Log.Level level : Log.Level.values()) { assertTrue(logSpi.isLoggable(String.class, level)); } }
/** * Lowest level logging method. * * @param clazz * Class that is being logged. * @param method * Method name that is being logged. * @param level * Logging level. * @param message * Message about the log. * @param ex * Exception to use process. */ public void log(Class<?> clazz, String method, Log.Level level, String message, Throwable ex) { if (isLoggable(level)) { _logImpl.log(clazz, method, level, message, ex); } }
logSpi.log(String.class, "checkLogFormtat", Log.Level.OK, MSG_EXP, EXCEPTION_EXP); pstrm.flush(); } finally {