[slf4j-dev] svn commit: r797 - in slf4j/trunk: jcl104-over-slf4j/src/main/java/org/apache/commons/logging/impl slf4j-api slf4j-api/src/main/java/org/slf4j slf4j-api/src/main/java/org/slf4j/helpers slf4j-api/src/main/java/org/slf4j/spi slf4j-jcl/src/main/java/org/slf4j/impl slf4j-jdk14/src/main/java/org/slf4j/impl slf4j-log4j12/src/main/java/org/slf4j/impl slf4j-nop/src/main/java/org/slf4j/impl slf4j-simple/src/main/java/org/slf4j/impl
ceki at slf4j.org
ceki at slf4j.org
Thu May 3 17:28:25 CEST 2007
Author: ceki
Date: Thu May 3 17:28:24 2007
New Revision: 797
Modified:
slf4j/trunk/jcl104-over-slf4j/src/main/java/org/apache/commons/logging/impl/SLF4JLocationAwareLog.java
slf4j/trunk/jcl104-over-slf4j/src/main/java/org/apache/commons/logging/impl/SLF4JLog.java
slf4j/trunk/slf4j-api/ (props changed)
slf4j/trunk/slf4j-api/src/main/java/org/slf4j/Logger.java
slf4j/trunk/slf4j-api/src/main/java/org/slf4j/helpers/MarkerIgnoringBase.java
slf4j/trunk/slf4j-api/src/main/java/org/slf4j/spi/LocationAwareLogger.java
slf4j/trunk/slf4j-jcl/src/main/java/org/slf4j/impl/JCLLoggerAdapter.java
slf4j/trunk/slf4j-jdk14/src/main/java/org/slf4j/impl/JDK14LoggerAdapter.java
slf4j/trunk/slf4j-log4j12/src/main/java/org/slf4j/impl/Log4jLoggerAdapter.java
slf4j/trunk/slf4j-nop/src/main/java/org/slf4j/impl/NOPLogger.java
slf4j/trunk/slf4j-simple/src/main/java/org/slf4j/impl/SimpleLogger.java
Log:
introducing the TRACE level
Modified: slf4j/trunk/jcl104-over-slf4j/src/main/java/org/apache/commons/logging/impl/SLF4JLocationAwareLog.java
==============================================================================
--- slf4j/trunk/jcl104-over-slf4j/src/main/java/org/apache/commons/logging/impl/SLF4JLocationAwareLog.java (original)
+++ slf4j/trunk/jcl104-over-slf4j/src/main/java/org/apache/commons/logging/impl/SLF4JLocationAwareLog.java Thu May 3 17:28:24 2007
@@ -54,11 +54,11 @@
}
/**
- * Delegates to the <code>isDebugEnabled<code> method of the wrapped
+ * Delegates to the <code>isTraceEnabled<code> method of the wrapped
* <code>org.slf4j.Logger</code> instance.
*/
public boolean isTraceEnabled() {
- return logger.isDebugEnabled();
+ return logger.isTraceEnabled();
}
/**
@@ -75,7 +75,7 @@
* @param message the message to log. Converted to {@link String}
*/
public void trace(Object message) {
- logger.log(null, FQCN, LocationAwareLogger.DEBUG_INT, String.valueOf(message), null);
+ logger.log(null, FQCN, LocationAwareLogger.TRACE_INT, String.valueOf(message), null);
}
/**
@@ -86,7 +86,7 @@
* @param t the exception to log
*/
public void trace(Object message, Throwable t) {
- logger.log(null, FQCN, LocationAwareLogger.DEBUG_INT, String.valueOf(message), t);
+ logger.log(null, FQCN, LocationAwareLogger.TRACE_INT, String.valueOf(message), t);
}
/**
Modified: slf4j/trunk/jcl104-over-slf4j/src/main/java/org/apache/commons/logging/impl/SLF4JLog.java
==============================================================================
--- slf4j/trunk/jcl104-over-slf4j/src/main/java/org/apache/commons/logging/impl/SLF4JLog.java (original)
+++ slf4j/trunk/jcl104-over-slf4j/src/main/java/org/apache/commons/logging/impl/SLF4JLog.java Thu May 3 17:28:24 2007
@@ -56,7 +56,7 @@
* <code>org.slf4j.Logger</code> instance.
*/
public boolean isTraceEnabled() {
- return logger.isDebugEnabled();
+ return logger.isTraceEnabled();
}
/**
@@ -73,7 +73,7 @@
* @param message the message to log. Converted to {@link String}
*/
public void trace(Object message) {
- logger.debug(String.valueOf(message));
+ logger.trace(String.valueOf(message));
}
/**
@@ -84,7 +84,7 @@
* @param t the exception to log
*/
public void trace(Object message, Throwable t) {
- logger.debug(String.valueOf(message), t);
+ logger.trace(String.valueOf(message), t);
}
/**
Modified: slf4j/trunk/slf4j-api/src/main/java/org/slf4j/Logger.java
==============================================================================
--- slf4j/trunk/slf4j-api/src/main/java/org/slf4j/Logger.java (original)
+++ slf4j/trunk/slf4j-api/src/main/java/org/slf4j/Logger.java Thu May 3 17:28:24 2007
@@ -47,12 +47,164 @@
public String getName();
/**
+ * Is the logger instance enabled for the TRACE level?
+ * @return True if this Logger is enabled for the TRACE level,
+ * false otherwise.
+ *
+ * @since 1.4
+ */
+ public boolean isTraceEnabled();
+
+
+ /**
+ * Log a message at the TRACE level.
+ *
+ * @param msg the message string to be logged
+ * @since 1.4
+ */
+ public void trace(String msg);
+
+
+ /**
+ * Log a message at the TRACE level according to the specified format
+ * and argument.
+ *
+ * <p>This form avoids superfluous object creation when the logger
+ * is disabled for the TRACE level. </p>
+ *
+ * @param format the format string
+ * @param arg the argument
+ *
+ * @since 1.4
+ */
+ public void trace(String format, Object arg);
+
+
+
+ /**
+ * Log a message at the TRACE level according to the specified format
+ * and arguments.
+ *
+ * <p>This form avoids superfluous object creation when the logger
+ * is disabled for the TRACE level. </p>
+ *
+ * @param format the format string
+ * @param arg1 the first argument
+ * @param arg2 the second argument
+ *
+ * @since 1.4
+ */
+ public void trace(String format, Object arg1, Object arg2);
+
+ /**
+ * Log a message at the TRACE level according to the specified format
+ * and arguments.
+ *
+ * <p>This form avoids superfluous object creation when the logger
+ * is disabled for the TRACE level. </p>
+ *
+ * @param format the format string
+ * @param argArray an array of arguments
+ *
+ * @since 1.4
+ */
+ public void trace(String format, Object[] argArray);
+
+ /**
+ * Log an exception (throwable) at the TRACE level with an
+ * accompanying message.
+ *
+ * @param msg the message accompanying the exception
+ * @param t the exception (throwable) to log
+ *
+ * @since 1.4
+ */
+ public void trace(String msg, Throwable t);
+
+
+ /**
+ * Similar to {@link #isTraceEnabled()} method except that the
+ * marker data is also taken into account.
+ *
+ * @param marker The marker data to take into consideration
+ *
+ * @since 1.4
+ */
+ public boolean isTraceEnabled(Marker marker);
+
+ /**
+ * Log a message with the specific Marker at the TRACE level.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param msg the message string to be logged
+ *
+ * @since 1.4
+ */
+ public void trace(Marker marker, String msg);
+
+ /**
+ * This method is similar to {@link #trace(String, Object)} method except that the
+ * marker data is also taken into consideration.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param format the format string
+ * @param arg the argument
+ *
+ * @since 1.4
+ */
+ public void trace(Marker marker, String format, Object arg);
+
+
+ /**
+ * This method is similar to {@link #trace(String, Object, Object)}
+ * method except that the marker data is also taken into
+ * consideration.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param format the format string
+ * @param arg1 the first argument
+ * @param arg2 the second argument
+ *
+ * @since 1.4
+ */
+ public void trace(Marker marker, String format, Object arg1, Object arg2);
+
+ /**
+ * This method is similar to {@link #trace(String, Object[])}
+ * method except that the marker data is also taken into
+ * consideration.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param format the format string
+ * @param argArray an array of arguments
+ *
+ * @since 1.4
+ */
+ public void trace(Marker marker, String format, Object[] argArray);
+
+
+ /**
+ * This method is similar to {@link #trace(String, Throwable)} method except that the
+ * marker data is also taken into consideration.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param msg the message accompanying the exception
+ * @param t the exception (throwable) to log
+ *
+ * @since 1.4
+ */
+ public void trace(Marker marker, String msg, Throwable t);
+
+
+ /**
* Is the logger instance enabled for the DEBUG level?
* @return True if this Logger is enabled for the DEBUG level,
* false otherwise.
+ *
*/
public boolean isDebugEnabled();
+
/**
* Log a message at the DEBUG level.
*
@@ -60,7 +212,7 @@
*/
public void debug(String msg);
-
+
/**
* Log a message at the DEBUG level according to the specified format
* and argument.
Modified: slf4j/trunk/slf4j-api/src/main/java/org/slf4j/helpers/MarkerIgnoringBase.java
==============================================================================
--- slf4j/trunk/slf4j-api/src/main/java/org/slf4j/helpers/MarkerIgnoringBase.java (original)
+++ slf4j/trunk/slf4j-api/src/main/java/org/slf4j/helpers/MarkerIgnoringBase.java Thu May 3 17:28:24 2007
@@ -38,6 +38,30 @@
*/
public abstract class MarkerIgnoringBase implements Logger {
+ public boolean isTraceEnabled(Marker marker) {
+ return isTraceEnabled();
+ }
+
+ public void trace(Marker marker, String msg) {
+ debug(msg);
+ }
+
+ public void trace(Marker marker, String format, Object arg) {
+ debug(format, arg);
+ }
+
+ public void trace(Marker marker, String format, Object arg1, Object arg2) {
+ debug(format, arg1, arg2);
+ }
+
+ public void trace(Marker marker, String format, Object[] argArray) {
+ debug(format, argArray);
+ }
+
+ public void trace(Marker marker, String msg, Throwable t) {
+ debug(msg, t);
+ }
+
public boolean isDebugEnabled(Marker marker) {
return isDebugEnabled();
}
Modified: slf4j/trunk/slf4j-api/src/main/java/org/slf4j/spi/LocationAwareLogger.java
==============================================================================
--- slf4j/trunk/slf4j-api/src/main/java/org/slf4j/spi/LocationAwareLogger.java (original)
+++ slf4j/trunk/slf4j-api/src/main/java/org/slf4j/spi/LocationAwareLogger.java Thu May 3 17:28:24 2007
@@ -15,10 +15,11 @@
*/
public interface LocationAwareLogger extends Logger {
- final public int DEBUG_INT = 0;
- final public int INFO_INT = 1;
- final public int WARN_INT = 2;
- final public int ERROR_INT = 3;
+ final public int TRACE_INT = 00;
+ final public int DEBUG_INT = 10;
+ final public int INFO_INT = 20;
+ final public int WARN_INT = 30;
+ final public int ERROR_INT = 40;
/**
Modified: slf4j/trunk/slf4j-jcl/src/main/java/org/slf4j/impl/JCLLoggerAdapter.java
==============================================================================
--- slf4j/trunk/slf4j-jcl/src/main/java/org/slf4j/impl/JCLLoggerAdapter.java (original)
+++ slf4j/trunk/slf4j-jcl/src/main/java/org/slf4j/impl/JCLLoggerAdapter.java Thu May 3 17:28:24 2007
@@ -61,6 +61,104 @@
}
/**
+ * Delegates to the {@link Log#isTraceEnabled} method of the underlying
+ * {@link Log} instance.
+ */
+ public boolean isTraceEnabled() {
+ return log.isTraceEnabled();
+ }
+
+ //
+
+ /**
+ * Delegates to the {@link Log#trace(java.lang.Object)} method of the underlying
+ * {@link Log} instance.
+ *
+ * @param msg - the message object to be logged
+ */
+ public void trace(String msg) {
+ log.trace(msg);
+ }
+
+ /**
+ * Delegates to the {@link Log#trace(java.lang.Object)} method of the underlying
+ * {@link Log} instance.
+ *
+ * <p>
+ * However, this form avoids superfluous object creation when the logger is disabled
+ * for level TRACE.
+ * </p>
+ *
+ * @param format
+ * the format string
+ * @param arg
+ * the argument
+ */
+ public void trace(String format, Object arg) {
+ if (log.isDebugEnabled()) {
+ String msgStr = MessageFormatter.format(format, arg);
+ log.trace(msgStr);
+ }
+ }
+
+ /**
+ * Delegates to the {@link Log#trace(java.lang.Object)} method of the underlying
+ * {@link Log} instance.
+ *
+ * <p>
+ * However, this form avoids superfluous object creation when the logger is disabled
+ * for level TRACE.
+ * </p>
+ *
+ * @param format
+ * the format string
+ * @param arg1
+ * the first argument
+ * @param arg2
+ * the second argument
+ */
+ public void trace(String format, Object arg1, Object arg2) {
+ if (log.isDebugEnabled()) {
+ String msgStr = MessageFormatter.format(format, arg1, arg2);
+ log.trace(msgStr);
+ }
+ }
+
+
+ /**
+ * Delegates to the {@link Log#trace(java.lang.Object)} method of the underlying
+ * {@link Log} instance.
+ *
+ * <p>
+ * However, this form avoids superfluous object creation when the logger is disabled
+ * for level TRACE.
+ * </p>
+ *
+ * @param format the format string
+ * @param argArray an array of arguments
+ */
+ public void trace(String format, Object[] argArray) {
+ if (log.isDebugEnabled()) {
+ String msgStr = MessageFormatter.arrayFormat(format, argArray);
+ log.trace(msgStr);
+ }
+ }
+
+ /**
+ * Delegates to the {@link Log#trace(java.lang.Object, java.lang.Throwable)} method of
+ * the underlying {@link Log} instance.
+ *
+ * @param msg
+ * the message accompanying the exception
+ * @param t
+ * the exception (throwable) to log
+ */
+ public void trace(String msg, Throwable t) {
+ log.trace(msg, t);
+ }
+
+
+ /**
* Delegates to the {@link Log#isDebugEnabled} method of the underlying
* {@link Log} instance.
*/
Modified: slf4j/trunk/slf4j-jdk14/src/main/java/org/slf4j/impl/JDK14LoggerAdapter.java
==============================================================================
--- slf4j/trunk/slf4j-jdk14/src/main/java/org/slf4j/impl/JDK14LoggerAdapter.java (original)
+++ slf4j/trunk/slf4j-jdk14/src/main/java/org/slf4j/impl/JDK14LoggerAdapter.java Thu May 3 17:28:24 2007
@@ -65,6 +65,102 @@
}
/**
+ * Is this logger instance enabled for the FINEST level?
+ *
+ * @return True if this Logger is enabled for level FINEST, false otherwise.
+ */
+ public boolean isTraceEnabled() {
+ return logger.isLoggable(Level.FINEST);
+ }
+
+ /**
+ * Log a message object at level FINEST.
+ *
+ * @param msg -
+ * the message object to be logged
+ */
+ public void trace(String msg) {
+ log(SELF, Level.FINEST, msg, null);
+ }
+
+ /**
+ * Log a message at level FINEST according to the specified format and argument.
+ *
+ * <p>
+ * This form avoids superfluous object creation when the logger is disabled
+ * for level FINEST.
+ * </p>
+ *
+ * @param format
+ * the format string
+ * @param arg
+ * the argument
+ */
+ public void trace(String format, Object arg) {
+ if (logger.isLoggable(Level.FINEST)) {
+ String msgStr = MessageFormatter.format(format, arg);
+ log(SELF, Level.FINEST, msgStr, null);
+ }
+ }
+
+ /**
+ * Log a message at level FINEST according to the specified format and
+ * arguments.
+ *
+ * <p>
+ * This form avoids superfluous object creation when the logger is disabled
+ * for the FINEST level.
+ * </p>
+ *
+ * @param format
+ * the format string
+ * @param arg1
+ * the first argument
+ * @param arg2
+ * the second argument
+ */
+ public void trace(String format, Object arg1, Object arg2) {
+ if (logger.isLoggable(Level.FINEST)) {
+ String msgStr = MessageFormatter.format(format, arg1, arg2);
+ log(SELF, Level.FINEST, msgStr, null);
+ }
+ }
+
+ /**
+ * Log a message at level FINEST according to the specified format and
+ * arguments.
+ *
+ * <p>
+ * This form avoids superfluous object creation when the logger is disabled
+ * for the FINEST level.
+ * </p>
+ *
+ * @param format
+ * the format string
+ * @param argArray
+ * an array of arguments
+ */
+ public void trace(String format, Object[] argArray) {
+ if (logger.isLoggable(Level.FINEST)) {
+ String msgStr = MessageFormatter.arrayFormat(format, argArray);
+ log(SELF, Level.FINEST, msgStr, null);
+ }
+ }
+
+ /**
+ * Log an exception (throwable) at level FINEST with an accompanying message.
+ *
+ * @param msg
+ * the message accompanying the exception
+ * @param t
+ * the exception (throwable) to log
+ */
+ public void trace(String msg, Throwable t) {
+ log(SELF, Level.FINEST, msg, t);
+ }
+
+
+ /**
* Is this logger instance enabled for the FINE level?
*
* @return True if this Logger is enabled for level FINE, false otherwise.
@@ -73,8 +169,6 @@
return logger.isLoggable(Level.FINE);
}
- //
-
/**
* Log a message object at level FINE.
*
@@ -513,6 +607,9 @@
public void log(Marker marker, String callerFQCN, int level, String message, Throwable t) {
Level julLevel;
switch(level) {
+ case LocationAwareLogger.TRACE_INT:
+ julLevel = Level.FINEST;
+ break;
case LocationAwareLogger.DEBUG_INT:
julLevel = Level.FINE;
break;
Modified: slf4j/trunk/slf4j-log4j12/src/main/java/org/slf4j/impl/Log4jLoggerAdapter.java
==============================================================================
--- slf4j/trunk/slf4j-log4j12/src/main/java/org/slf4j/impl/Log4jLoggerAdapter.java (original)
+++ slf4j/trunk/slf4j-log4j12/src/main/java/org/slf4j/impl/Log4jLoggerAdapter.java Thu May 3 17:28:24 2007
@@ -70,6 +70,89 @@
public String getName() {
return logger.getName();
}
+
+ /**
+ * Is this logger instance enabled for the TRACE level?
+ *
+ * @return True if this Logger is enabled for level TRACE, false
+ * otherwise.
+ */
+ public boolean isTraceEnabled() {
+ return logger.isTraceEnabled();
+ }
+
+
+ /**
+ * Log a message object at level TRACE.
+ * @param msg - the message object to be logged
+ */
+ public void trace(String msg) {
+ logger.log(FQCN, Level.DEBUG, msg, null);
+ }
+
+ /**
+ * Log a message at level TRACE according to the specified format and
+ * argument.
+ *
+ * <p>This form avoids superfluous object creation when the logger
+ * is disabled for level TRACE. </p>
+ *
+ * @param format the format string
+ * @param arg the argument
+ */
+ public void trace(String format, Object arg) {
+ if (logger.isTraceEnabled()) {
+ String msgStr = MessageFormatter.format(format, arg);
+ logger.log(FQCN, Level.TRACE, msgStr, null);
+ }
+ }
+
+ /**
+ * Log a message at level TRACE according to the specified format and
+ * arguments.
+ *
+ * <p>This form avoids superfluous object creation when the logger
+ * is disabled for the TRACE level. </p>
+ *
+ * @param format the format string
+ * @param arg1 the first argument
+ * @param arg2 the second argument
+ */
+ public void trace(String format, Object arg1, Object arg2) {
+ if (logger.isTraceEnabled()) {
+ String msgStr = MessageFormatter.format(format, arg1, arg2);
+ logger.log(FQCN, Level.TRACE, msgStr, null);
+ }
+ }
+
+ /**
+ * Log a message at level TRACE according to the specified format and
+ * arguments.
+ *
+ * <p>This form avoids superfluous object creation when the logger
+ * is disabled for the TRACE level. </p>
+ *
+ * @param format the format string
+ * @param argArray an array of arguments
+ */
+ public void trace(String format, Object[] argArray) {
+ if (logger.isTraceEnabled()) {
+ String msgStr = MessageFormatter.arrayFormat(format, argArray);
+ logger.log(FQCN, Level.TRACE, msgStr, null);
+ }
+ }
+
+ /**
+ * Log an exception (throwable) at level TRACE with an
+ * accompanying message.
+ *
+ * @param msg the message accompanying the exception
+ * @param t the exception (throwable) to log
+ */
+ public void trace(String msg, Throwable t) {
+ logger.log(FQCN, Level.TRACE, msg, t);
+ }
+
/**
* Is this logger instance enabled for the DEBUG level?
@@ -405,6 +488,9 @@
public void log(Marker marker, String callerFQCN, int level, String msg, Throwable t) {
Level log4jLevel;
switch(level) {
+ case LocationAwareLogger.TRACE_INT:
+ log4jLevel = Level.TRACE;
+ break;
case LocationAwareLogger.DEBUG_INT:
log4jLevel = Level.DEBUG;
break;
Modified: slf4j/trunk/slf4j-nop/src/main/java/org/slf4j/impl/NOPLogger.java
==============================================================================
--- slf4j/trunk/slf4j-nop/src/main/java/org/slf4j/impl/NOPLogger.java (original)
+++ slf4j/trunk/slf4j-nop/src/main/java/org/slf4j/impl/NOPLogger.java Thu May 3 17:28:24 2007
@@ -66,6 +66,39 @@
* Always returns false.
* @return always false
*/
+ final public boolean isTraceEnabled() {
+ return false;
+ }
+
+ /** A NOP implementation. */
+ final public void trace(String msg) {
+ // NOP
+ }
+
+ /** A NOP implementation. */
+ final public void trace(String format, Object arg) {
+ // NOP
+ }
+
+ /** A NOP implementation. */
+ public final void trace(String format, Object arg1, Object arg2) {
+ // NOP
+ }
+
+ /** A NOP implementation. */
+ public final void trace(String format, Object[] argArray) {
+ // NOP
+ }
+
+ /** A NOP implementation. */
+ final public void trace(String msg, Throwable t) {
+ // NOP
+ }
+
+ /**
+ * Always returns false.
+ * @return always false
+ */
final public boolean isDebugEnabled() {
return false;
}
Modified: slf4j/trunk/slf4j-simple/src/main/java/org/slf4j/impl/SimpleLogger.java
==============================================================================
--- slf4j/trunk/slf4j-simple/src/main/java/org/slf4j/impl/SimpleLogger.java (original)
+++ slf4j/trunk/slf4j-simple/src/main/java/org/slf4j/impl/SimpleLogger.java Thu May 3 17:28:24 2007
@@ -84,6 +84,53 @@
public String getName() {
return name;
}
+
+ /**
+ * Always returns false.
+ * @return always false
+ */
+ public boolean isTraceEnabled() {
+ return false;
+ }
+
+ /**
+ * A NOP implementation, as this logger is permanently disabled for
+ * the TRACE level.
+ */
+ public void trace(String msg) {
+ // NOP
+ }
+
+ /**
+ * A NOP implementation, as this logger is permanently disabled for
+ * the TRACE level.
+ */
+ public void trace(String format, Object param1) {
+ // NOP
+ }
+
+
+ /**
+ * A NOP implementation, as this logger is permanently disabled for
+ * the TRACE level.
+ */
+ public void trace(String format, Object param1, Object param2) {
+ // NOP
+ }
+
+ public void trace(String format, Object[] argArray) {
+ // NOP
+ }
+
+ /**
+ * A NOP implementation, as this logger is permanently disabled for
+ * the TRACE level.
+ */
+ public void trace(String msg, Throwable t) {
+ // NOP
+ }
+
+
/**
* Always returns false.
* @return always false
More information about the slf4j-dev
mailing list