[slf4j-dev] svn commit: r1085 - slf4j/trunk/slf4j-jdk14/src/main/java/org/slf4j/impl

ceki at slf4j.org ceki at slf4j.org
Thu Jul 31 16:55:51 CEST 2008


Author: ceki
Date: Thu Jul 31 16:55:51 2008
New Revision: 1085

Modified:
   slf4j/trunk/slf4j-jdk14/src/main/java/org/slf4j/impl/JDK14LoggerAdapter.java

Log:

- added a check before invoking JUL logger. This check improves 
  performance for disabled log statements. Moreover, it is not redundant 
  as callers of the LocationAwareLogger.log method in various bridges do not
  perform the check (at this time).
  
  This fixes bug 90, http://bugzilla.slf4j.org/show_bug.cgi?id=90

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 Jul 31 16:55:51 2008
@@ -626,7 +626,7 @@
       record.setSourceMethodName(ste.getMethodName());
     }
   }
-
+ 
   public void log(Marker marker, String callerFQCN, int level, String message,
       Throwable t) {
     Level julLevel;
@@ -650,6 +650,13 @@
       throw new IllegalStateException("Level number " + level
           + " is not recognized.");
     }
-    log(callerFQCN, julLevel, message, t);
+    // the logger.isLoggable check avoids the unconditional 
+    // construction of location data for disabled log
+    // statements. As of 2008-07-31, callers of this method 
+    // do not perform this check. See also 
+    // http://bugzilla.slf4j.org/show_bug.cgi?id=90
+    if(logger.isLoggable(julLevel)) {
+      log(callerFQCN, julLevel, message, t);
+    }
   }
 }



More information about the slf4j-dev mailing list