[slf4j-dev] svn commit: r1118 - slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j

ceki at slf4j.org ceki at slf4j.org
Wed Aug 20 16:32:38 CEST 2008


Author: ceki
Date: Wed Aug 20 16:32:37 2008
New Revision: 1118

Modified:
   slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Category.java
   slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Logger.java
   slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Priority.java

Log:
- method signatures match those in log4j 1.2 instead of log4j 1.3 as previously.

Modified: slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Category.java
==============================================================================
--- slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Category.java	(original)
+++ slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Category.java	Wed Aug 20 16:32:37 2008
@@ -23,8 +23,8 @@
 /**
  * <p>
  * This class is a minimal implementation of the original
- * <code>org.apache.log4j.Logger</code> class by delegation of all calls 
- * to a {@link org.slf4j.Logger.Logger} instance.
+ * <code>org.apache.log4j.Category</code> class (as found in log4j 1.2) 
+ * by delegation of all calls to a {@link org.slf4j.Logger.Logger} instance.
  * </p>
  * 
  * <p>
@@ -37,12 +37,11 @@
  * @author S&eacute;bastien Pennec
  * @author Ceki G&uuml;lc&uuml;
  */
-
 public class Category {
 
   private String name;
 
-  private org.slf4j.Logger slf4jLogger;
+  protected org.slf4j.Logger slf4jLogger;
   private org.slf4j.spi.LocationAwareLogger locationAwareLogger;
   
   private static Marker FATAL_MARKER = MarkerFactory.getMarker("FATAL");
@@ -55,31 +54,14 @@
     }
   }
 
-  public static Logger getInstance(Class clazz) {
-    return getLogger(clazz);
-  }
-
-  public static Logger getInstance(String name) {
-    return getLogger(name);
+  public static Category getInstance(Class clazz) {
+    return Log4jLoggerFactory.getLogger(clazz.getName());
   }
 
-  public static Logger getLogger(String name) {
+  public static Category getInstance(String name) {
     return Log4jLoggerFactory.getLogger(name);
   }
 
-  public static Logger getLogger(Class clazz) {
-    return getLogger(clazz.getName());
-  }
-
-  /**
-   * Does the obvious.
-   * 
-   * @return
-   */
-  public static Logger getRootLogger() {
-    return getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
-  }
-
   /**
    * Returns the obvious.
    * 
@@ -132,14 +114,6 @@
   }
   
   /**
-   * Delegates to {@link org.slf4j.Logger#isTraceEnabled} 
-   * method of SLF4J.
-   */
-  public boolean isTraceEnabled() {
-    return slf4jLogger.isTraceEnabled();
-  }
-
-  /**
    * Delegates to {@link org.slf4j.Logger#isDebugEnabled} method in  SLF4J
    */
   public boolean isDebugEnabled() {
@@ -154,7 +128,7 @@
   }
 
   /**
-   * Delegates to {@link org.slf4j.Logger#isWarnEnabled} method in  SLF4J
+   * Delegates tob {@link org.slf4j.Logger#isWarnEnabled} method in  SLF4J
    */
   public boolean isWarnEnabled() {
     return slf4jLogger.isWarnEnabled();
@@ -167,26 +141,17 @@
     return slf4jLogger.isErrorEnabled();
   }
   
-  /**
-   * Delegates to {@link #isEnabledFor(Level)}.
-   * 
-   * @param p the priority to check against
-   * @return true if this logger is enabled for the given priority, false otehrwise.
-   */
-  public boolean isEnabledFor(Priority p) {
-    return isEnabledFor(Level.toLevel(p.level));
-  }
 
   /**
-   * Determines whether the level passes as parameter is enabled in
-   * the underlying SLF4J logger. Each log4j level is mapped directly to
+   * Determines whether the priority passed as parameter is enabled in
+   * the underlying SLF4J logger. Each log4j priority is mapped directly to
    * its SLF4J equivalent, except for FATAL which is mapped as ERROR. 
    * 
-   * @param l the level to check against
-   * @return true if this logger is enabled for the given level, false otehrwise.
+   * @param p the priority to check against
+   * @return true if this logger is enabled for the given level, false otherwise.
    */
-  public boolean isEnabledFor(Level l) {
-    switch (l.level) {
+  public boolean isEnabledFor(Priority p) {
+    switch (p.level) {
     case Level.TRACE_INT:
       return slf4jLogger.isTraceEnabled();
     case Level.DEBUG_INT:
@@ -203,22 +168,6 @@
     return false;
   }
 
-  /**
-   * Delegates to {@link org.slf4j.Logger#trace(String)} method in SLF4J.
-   */
-  public void trace(Object message) {
-    // casting to String as SLF4J only accepts String instances, not Object
-    // instances.
-    slf4jLogger.trace(convertToString(message));
-  }
-
-  /**
-   * Delegates to {@link org.slf4j.Logger#trace(String,Throwable)} 
-   * method in SLF4J.
-   */
-  public void trace(Object message, Throwable t) {
-    slf4jLogger.trace(convertToString(message), t);
-  }
   
   /**
    * Delegates to {@link org.slf4j.Logger#debug(String)} method of
@@ -336,7 +285,7 @@
     }
   }
   
-  private final String convertToString(Object message) {
+  protected final String convertToString(Object message) {
     if (message == null) {
       return (String)message;
     } else {

Modified: slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Logger.java
==============================================================================
--- slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Logger.java	(original)
+++ slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Logger.java	Wed Aug 20 16:32:37 2008
@@ -16,10 +16,62 @@
 
 package org.apache.log4j;
 
+/**
+ * <p>
+ * This class is a minimal implementation of the original
+ * <code>org.apache.log4j.Logger</code> class (as found in log4j 1.2) 
+ * by delegation of all calls to a {@link org.slf4j.Logger.Logger} instance.
+ * </p>
+ *
+ * @author Ceki G&uuml;lc&uuml; 
+ * */
 public class Logger extends Category {
 
   Logger(String name) {
     super(name);
   }
 
+  public static Logger getLogger(String name) {
+    return Log4jLoggerFactory.getLogger(name);
+  }
+
+  public static Logger getLogger(Class clazz) {
+    return getLogger(clazz.getName());
+  }
+  
+  /**
+   * Does the obvious.
+   * 
+   * @return
+   */
+  public static Logger getRootLogger() {
+    return Log4jLoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
+  }
+
+  
+  /**
+   * Delegates to {@link org.slf4j.Logger#isTraceEnabled} 
+   * method of SLF4J.
+   */
+  public boolean isTraceEnabled() {
+    return slf4jLogger.isTraceEnabled();
+  }
+  
+  /**
+   * Delegates to {@link org.slf4j.Logger#trace(String)} method in SLF4J.
+   */
+  public void trace(Object message) {
+    // casting to String as SLF4J only accepts String instances, not Object
+    // instances.
+    slf4jLogger.trace(convertToString(message));
+  }
+
+  /**
+   * Delegates to {@link org.slf4j.Logger#trace(String,Throwable)} 
+   * method in SLF4J.
+   */
+  public void trace(Object message, Throwable t) {
+    slf4jLogger.trace(convertToString(message), t);
+  }
+
 }

Modified: slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Priority.java
==============================================================================
--- slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Priority.java	(original)
+++ slf4j/trunk/log4j-over-slf4j/src/main/java/org/apache/log4j/Priority.java	Wed Aug 20 16:32:37 2008
@@ -18,6 +18,8 @@
 
 package org.apache.log4j;
 
+// Contributors:  Kitching Simon <Simon.Kitching at OOOrange.ch>
+
 /**
    <font color="#AA4444">Refrain from using this class directly, use
    the {@link Level} class instead</font>.



More information about the slf4j-dev mailing list