LOG4J2-1326 add methods isEnabled and logIfEnabled that accept a CharSequence to ExtendedLogger
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/e014796e Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/e014796e Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/e014796e Branch: refs/heads/LOG4J2-1356 Commit: e014796e114f206bd073606ec60436f3e1caf94b Parents: 9107a04 Author: rpopma <[email protected]> Authored: Thu Apr 7 22:13:40 2016 +0900 Committer: rpopma <[email protected]> Committed: Thu Apr 7 22:13:40 2016 +0900 ---------------------------------------------------------------------- .../logging/log4j/spi/ExtendedLogger.java | 23 ++++++++++++++++++++ .../log4j/spi/ExtendedLoggerWrapper.java | 14 ++++++++++++ 2 files changed, 37 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/e014796e/log4j-api/src/main/java/org/apache/logging/log4j/spi/ExtendedLogger.java ---------------------------------------------------------------------- diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/spi/ExtendedLogger.java b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ExtendedLogger.java index fc3a76c..2e90a03 100644 --- a/log4j-api/src/main/java/org/apache/logging/log4j/spi/ExtendedLogger.java +++ b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ExtendedLogger.java @@ -49,6 +49,17 @@ public interface ExtendedLogger extends Logger { * @param t A Throwable. * @return True if logging is enabled, false otherwise. */ + boolean isEnabled(Level level, Marker marker, CharSequence message, Throwable t); + + /** + * Determines if logging is enabled. + * + * @param level The logging Level to check. + * @param marker A Marker or null. + * @param message The message. + * @param t A Throwable. + * @return True if logging is enabled, false otherwise. + */ boolean isEnabled(Level level, Marker marker, Object message, Throwable t); /** @@ -257,6 +268,18 @@ public interface ExtendedLogger extends Logger { void logIfEnabled(String fqcn, Level level, Marker marker, Message message, Throwable t); /** + * Logs a CharSequence message if the specified level is active. + * + * @param fqcn The fully qualified class name of the logger entry point, used to determine the caller class and + * method when location information needs to be logged. + * @param level The logging Level to check. + * @param marker A Marker or null. + * @param message The CharSequence message. + * @param t the exception to log, including its stack trace. + */ + void logIfEnabled(String fqcn, Level level, Marker marker, CharSequence message, Throwable t); + + /** * Logs a message if the specified level is active. * * @param fqcn The fully qualified class name of the logger entry point, used to determine the caller class and http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/e014796e/log4j-api/src/main/java/org/apache/logging/log4j/spi/ExtendedLoggerWrapper.java ---------------------------------------------------------------------- diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/spi/ExtendedLoggerWrapper.java b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ExtendedLoggerWrapper.java index 6c00755..c3fdc88 100644 --- a/log4j-api/src/main/java/org/apache/logging/log4j/spi/ExtendedLoggerWrapper.java +++ b/log4j-api/src/main/java/org/apache/logging/log4j/spi/ExtendedLoggerWrapper.java @@ -69,6 +69,20 @@ public class ExtendedLoggerWrapper extends AbstractLogger { * * @param level The logging Level to check. * @param marker A Marker or null. + * @param message The message CharSequence. + * @param t A Throwable. + * @return true if the event would be logged for the Level, Marker, Object and Throwable, false otherwise. + */ + @Override + public boolean isEnabled(final Level level, final Marker marker, final CharSequence message, final Throwable t) { + return logger.isEnabled(level, marker, message, t); + } + + /** + * Detect if the event would be logged. + * + * @param level The logging Level to check. + * @param marker A Marker or null. * @param message The message. * @param t A Throwable. * @return true if the event would be logged for the Level, Marker, Object and Throwable, false otherwise.
