[slf4j-dev] svn commit: r481 - in slf4j/trunk: src/java/org/apache/commons/logging/impl tests/src/java/org/apache/commons/logging

ceki at slf4j.org ceki at slf4j.org
Mon Jan 9 17:02:34 CET 2006


Author: ceki
Date: Mon Jan  9 17:02:32 2006
New Revision: 481

Modified:
   slf4j/trunk/src/java/org/apache/commons/logging/impl/SLF4JLog.java
   slf4j/trunk/tests/src/java/org/apache/commons/logging/InvokeJCLTest.java
Log:

Fix in case message is null.

See bug #12 for more details http://bugzilla.slf4j.org/show_bug.cgi?id=12

Modified: slf4j/trunk/src/java/org/apache/commons/logging/impl/SLF4JLog.java
==============================================================================
--- slf4j/trunk/src/java/org/apache/commons/logging/impl/SLF4JLog.java	(original)
+++ slf4j/trunk/src/java/org/apache/commons/logging/impl/SLF4JLog.java	Mon Jan  9 17:02:32 2006
@@ -73,7 +73,7 @@
    * @param message the message to log. Converted to {@link String}  
    */
   public void trace(Object message) {
-    logger.debug(message.toString());
+    logger.debug(String.valueOf(message));
   }
 
   /**
@@ -84,7 +84,7 @@
    * @param t the exception to log
    */
   public void trace(Object message, Throwable t) {
-    logger.debug(message.toString(), t);
+    logger.debug(String.valueOf(message), t);
   }
 
   /**
@@ -94,7 +94,7 @@
    * @param message the message to log. Converted to {@link String} 
    */
   public void debug(Object message) {
-    logger.debug(message.toString());
+    logger.debug(String.valueOf(message));
   }
 
   /**
@@ -105,7 +105,7 @@
    * @param t the exception to log
    */
   public void debug(Object message, Throwable t) {
-    logger.debug(message.toString(), t);
+    logger.debug(String.valueOf(message), t);
   }
 
   /**
@@ -115,7 +115,7 @@
    * @param message the message to log. Converted to {@link String} 
    */
   public void info(Object message) {
-    logger.info(message.toString());
+    logger.info(String.valueOf(message));
   }
 
   /**
@@ -126,7 +126,7 @@
    * @param t the exception to log
    */
   public void info(Object message, Throwable t) {
-    logger.info(message.toString(), t);
+    logger.info(String.valueOf(message), t);
   }
 
   /**
@@ -136,7 +136,7 @@
    * @param message the message to log. Converted to {@link String}  
    */
   public void warn(Object message) {
-    logger.warn(message.toString());
+    logger.warn(String.valueOf(message));
   }
 
   /**
@@ -147,7 +147,7 @@
    * @param t the exception to log
    */
   public void warn(Object message, Throwable t) {
-    logger.warn(message.toString(), t);
+    logger.warn(String.valueOf(message), t);
   }
 
   /**
@@ -157,7 +157,7 @@
    * @param message the message to log. Converted to {@link String}  
    */
   public void error(Object message) {
-    logger.error(message.toString());
+    logger.error(String.valueOf(message));
   }
 
   /**
@@ -168,7 +168,7 @@
    * @param t the exception to log
    */
   public void error(Object message, Throwable t) {
-    logger.error(message.toString(), t);
+    logger.error(String.valueOf(message), t);
   }
 
 
@@ -180,7 +180,7 @@
    * @param message the message to log. Converted to {@link String}  
    */
   public void fatal(Object message) {
-    logger.error(message.toString());
+    logger.error(String.valueOf(message));
   }
 
   /**
@@ -191,7 +191,7 @@
    * @param t the exception to log
    */
   public void fatal(Object message, Throwable t) {
-    logger.error(message.toString(), t);
+    logger.error(String.valueOf(message), t);
   }
 
 }
\ No newline at end of file

Modified: slf4j/trunk/tests/src/java/org/apache/commons/logging/InvokeJCLTest.java
==============================================================================
--- slf4j/trunk/tests/src/java/org/apache/commons/logging/InvokeJCLTest.java	(original)
+++ slf4j/trunk/tests/src/java/org/apache/commons/logging/InvokeJCLTest.java	Mon Jan  9 17:02:32 2006
@@ -53,18 +53,42 @@
   public void testPrintAPI() {
     Log log = LogFactory.getLog(InvokeJCLTest.class);
     Exception e = new Exception("just testing");
+  
+    log.trace(null);
     log.trace("trace message");
+    
+    log.debug(null);
     log.debug("debug message");
+    
+    log.info(null);
     log.info("info  message");
+    
+    log.warn(null);
     log.warn("warn message");
+
+    log.error(null);
     log.error("error message");
+
+    log.fatal(null);
     log.fatal("fatal message");
     
+
+    log.trace(null, e);
     log.trace("trace message", e);
+    
+    log.debug(null, e);
     log.debug("debug message", e);
+    
+    log.info(null, e);    
     log.info("info  message", e);
+    
+    log.warn(null, e);
     log.warn("warn message", e);
+    
+    log.error(null, e);
     log.error("error message", e);
+    
+    log.fatal(null, e);
     log.fatal("fatal message", e);
   }
 }



More information about the slf4j-dev mailing list