[logback-dev] svn commit: r1522 - in logback/trunk/logback-classic/src: main/java/ch/qos/logback/classic test/java/ch/qos/logback/classic test/java/ch/qos/logback/classic/control

noreply.ceki at qos.ch noreply.ceki at qos.ch
Thu May 3 20:45:08 CEST 2007


Author: ceki
Date: Thu May  3 20:45:07 2007
New Revision: 1522

Modified:
   logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/Level.java
   logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/HLogger.java
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/control/ControlLogger.java

Log:

Added trace methods to syncing with SLF4J version 1.4.0

Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/Level.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/Level.java	(original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/Level.java	Thu May  3 20:45:07 2007
@@ -11,10 +11,10 @@
 package ch.qos.logback.classic;
 
 /**
- * Defines the set of levels recognized by the LOGBback, that is {@link #OFF},
- * {@link #ERROR}, {@link #WARN}, {@link #INFO} and {@link #DEBUG},
- * {@link #ALL}. <p/> The <code>Level</code> class is final and cannot be
- * sub-classed.
+ * Defines the set of levels recognized by logback-classic, that is {@link #OFF},
+ * {@link #ERROR}, {@link #WARN}, {@link #INFO}, {@link #DEBUG},
+ * {@link #TRACE} and {@link #ALL}. <p/> The <code>Level</code> class is
+ * final and cannot be sub-classed.
  * </p>
  */
 public final class Level implements java.io.Serializable {
@@ -26,6 +26,7 @@
   public static final int WARN_INT = 30000;
   public static final int INFO_INT = 20000;
   public static final int DEBUG_INT = 10000;
+  public static final int TRACE_INT = 5000;
   public static final int ALL_INT = Integer.MIN_VALUE;
 
   public static final Integer OFF_INTEGER = new Integer(OFF_INT);
@@ -33,6 +34,7 @@
   public static final Integer WARN_INTEGER = new Integer(WARN_INT);
   public static final Integer INFO_INTEGER = new Integer(INFO_INT);
   public static final Integer DEBUG_INTEGER = new Integer(DEBUG_INT);
+  public static final Integer TRACE_INTEGER = new Integer(DEBUG_INT);
   public static final Integer ALL_INTEGER = new Integer(ALL_INT);
 
   /**
@@ -41,29 +43,35 @@
   public static final Level OFF = new Level(OFF_INT, "OFF");
 
   /**
-   * The <code>ERROR</code> levelInt designates error events which may or not
+   * The <code>ERROR</code> level designates error events which may or not
    * be fatal to the application.
    */
   public static final Level ERROR = new Level(ERROR_INT, "ERROR");
 
   /**
-   * The <code>WARN</code> levelInt designates potentially harmful situations.
+   * The <code>WARN</code> level designates potentially harmful situations.
    */
   public static final Level WARN = new Level(WARN_INT, "WARN");
 
   /**
-   * The <code>INFO</code> levelInt designates informational messages
+   * The <code>INFO</code> level designates informational messages
    * highlighting overall progress of the application.
    */
   public static final Level INFO = new Level(INFO_INT, "INFO");
 
   /**
-   * The <code>DEBUG</code> levelInt designates informational events of lower
+   * The <code>DEBUG</code> level designates informational events of lower
    * importance.
    */
   public static final Level DEBUG = new Level(DEBUG_INT, "DEBUG");
 
   /**
+   * The <code>TRACE</code> level designates informational events of very low
+   * importance.
+   */
+  public static final Level TRACE = new Level(TRACE_INT, "TRACE");
+
+  /**
    * The <code>ALL</code> is used to turn on all logging.
    */
   public static final Level ALL = new Level(ALL_INT, "ALL");
@@ -95,12 +103,15 @@
 
   /**
    * Convert a Level to an Integer object.
+   * 
    * @return This level's Integer mapping.
    */
   public final Integer toInteger() {
     switch (levelInt) {
     case ALL_INT:
       return ALL_INTEGER;
+    case TRACE_INT:
+      return TRACE_INTEGER;
     case DEBUG_INT:
       return DEBUG_INTEGER;
     case INFO_INT:
@@ -149,6 +160,8 @@
     switch (val) {
     case ALL_INT:
       return ALL;
+    case TRACE_INT:
+      return TRACE;
     case DEBUG_INT:
       return DEBUG;
     case INFO_INT:
@@ -176,6 +189,9 @@
     if (sArg.equalsIgnoreCase("ALL")) {
       return Level.ALL;
     }
+    if (sArg.equalsIgnoreCase("TRACE")) {
+      return Level.TRACE;
+    }
     if (sArg.equalsIgnoreCase("DEBUG")) {
       return Level.DEBUG;
     }

Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java	(original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java	Thu May  3 20:45:07 2007
@@ -370,6 +370,32 @@
     return childLogger;
   }
 
+  public void trace(String msg) {
+    filterAndLog(FQCN, null, Level.TRACE, msg, null, null);
+  }
+
+  public final void trace(String format, Object arg) {
+    filterAndLog(FQCN, null, Level.TRACE, format, arg, null);
+  }
+
+  public void trace(String format, Object arg1, Object arg2) {
+    filterAndLog(FQCN, null, Level.TRACE, format, arg1, arg2, null);
+  }
+
+  public void trace(String format, Object[] argArray) {
+    filterAndLog(FQCN, null, Level.TRACE, format, argArray, null);
+  }
+
+  public void trace(String msg, Throwable t) {
+    if (isDebugEnabled()) {
+      filterAndLog(FQCN, null, Level.TRACE, msg, null, t);
+    }
+  }
+
+  public final void trace(Marker marker, String msg) {
+    filterAndLog(FQCN, marker, Level.TRACE, msg, null, null);
+  }
+  
   public void debug(String msg) {
     filterAndLog(FQCN, null, Level.DEBUG, msg, null, null);
   }
@@ -471,6 +497,23 @@
     filterAndLog(FQCN, marker, level, msg, param1, param2, t);
   }
 
+  public void trace(Marker marker, String format, Object arg) {
+    filterAndLog(FQCN, marker, Level.TRACE, format, arg, null);
+  }
+
+  public void trace(Marker marker, String format, Object arg1, Object arg2) {
+    filterAndLog(FQCN, marker, Level.TRACE, format, arg1, arg2, null);
+  }
+
+  public void trace(Marker marker, String format, Object[] argArray) {
+    filterAndLog(FQCN, marker, Level.TRACE, format, argArray, null);
+  }
+
+  public void trace(Marker marker, String msg, Throwable t) {
+    filterAndLog(FQCN, marker, Level.TRACE, msg, null, t);
+  }
+
+  
   public void debug(Marker marker, String format, Object arg) {
     filterAndLog(FQCN, marker, Level.DEBUG, format, arg, null);
   }
@@ -567,10 +610,28 @@
     filterAndLog(FQCN, marker, Level.INFO, msg, null, t);
   }
 
+  public final boolean isTraceEnabled() {
+    return isTraceEnabled(null);
+  }
+
+  
   public final boolean isDebugEnabled() {
     return isDebugEnabled(null);
   }
 
+  public boolean isTraceEnabled(Marker marker) {
+    final FilterReply decision = callTurboFilters(marker, Level.TRACE);
+    if (decision == FilterReply.NEUTRAL) {
+      return effectiveLevelInt <= Level.TRACE_INT;
+    } else if (decision == FilterReply.DENY) {
+      return false;
+    } else if (decision == FilterReply.ACCEPT) {
+      return true;
+    } else {
+      throw new IllegalStateException("Unknown FilterReply value: " + decision);
+    }
+  }
+
   public boolean isDebugEnabled(Marker marker) {
     final FilterReply decision = callTurboFilters(marker, Level.DEBUG);
     if (decision == FilterReply.NEUTRAL) {
@@ -582,7 +643,6 @@
     } else {
       throw new IllegalStateException("Unknown FilterReply value: " + decision);
     }
-   
   }
 
   public final boolean isErrorEnabled() {

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/HLogger.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/HLogger.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/HLogger.java	Thu May  3 20:45:07 2007
@@ -253,6 +253,29 @@
     childHLogger.effectiveLevel = this.effectiveLevel;
     return childHLogger;
   }
+  
+  public final void trace(String msg) {
+    if (effectiveLevel.levelInt <= Level.TRACE_INT) {
+      throw new UnsupportedOperationException("not yet implemented");
+    }
+  }
+
+  public void trace(String msg, Throwable t) {
+    // To change body of implemented methods use File | Settings | File
+    // Templates.
+  }
+
+  public void trace(Object parameterizedMsg, Object param1) {
+    // To change body of implemented methods use File | Settings | File
+    // Templates.
+  }
+
+  public void trace(String parameterizedMsg, Object param1, Object param2) {
+    // To change body of implemented methods use File | Settings | File
+    // Templates.
+  }
+
+  
 
   public final void debug(String msg) {
     if (effectiveLevel.levelInt <= Level.DEBUG_INT) {
@@ -315,9 +338,12 @@
     // Templates.
   }
 
+  public boolean isTraceEnabled() {
+    return false; 
+  }
+  
   public boolean isDebugEnabled() {
-    return false; // To change body of implemented methods use File | Settings |
-    // File Templates.
+    return false; 
   }
 
   public boolean isErrorEnabled() {
@@ -355,6 +381,12 @@
     // Templates.
   }
 
+  public void trace(String format, Object arg) {
+  }
+
+  public void trace(String format, Object[] argArray) {
+  }
+  
   public void debug(String format, Object arg) {
   }
 

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/control/ControlLogger.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/control/ControlLogger.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/control/ControlLogger.java	Thu May  3 20:45:07 2007
@@ -61,6 +61,24 @@
     return name.hashCode();
   }
 
+  public final void trace(String o) {
+    if(getEffectiveLevel().levelInt <= Level.TRACE_INT ) {
+      throw new UnsupportedOperationException("not yet implemented");
+    }
+  }
+
+  public void trace(String msg, Throwable t) {
+    //To change body of implemented methods use File | Settings | File Templates.
+  }
+
+  public void trace(String parameterizedMsg, Object param1) {
+    //To change body of implemented methods use File | Settings | File Templates.
+  }
+
+  public void trace(String parameterizedMsg, Object param1, Object param2) {
+    //To change body of implemented methods use File | Settings | File Templates.
+  }
+  
   public final void debug(String o) {
     if(getEffectiveLevel().levelInt <= Level.DEBUG_INT ) {
       throw new UnsupportedOperationException("not yet implemented");
@@ -111,6 +129,10 @@
     //To change body of implemented methods use File | Settings | File Templates.
   }
 
+  public boolean isTraceEnabled() {
+    return false;  
+  }
+  
   public boolean isDebugEnabled() {
     return false;  //To change body of implemented methods use File | Settings | File Templates.
   }
@@ -143,6 +165,8 @@
     //To change body of implemented methods use File | Settings | File Templates.
   }
 
+  public void trace(String format, Object[] argArray) {
+  }
   public void debug(String format, Object[] argArray) {
   }
   public void info(String format, Object[] argArray) {



More information about the logback-dev mailing list