cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From andreasm...@apache.org
Subject svn commit: r523605 - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/phase/ common/common/src/main/java/org/apache/cxf/common/logging/ common/common/src/test/java/org/apache/cxf/common/logging/
Date Thu, 29 Mar 2007 07:46:55 GMT
Author: andreasmyth
Date: Thu Mar 29 00:46:54 2007
New Revision: 523605

URL: http://svn.apache.org/viewvc?view=rev&rev=523605
Log:
Fix for LogUtils.log(Logger, Level, String, Throwable) not setting throwable (a real pain
in PhaseInterceptorChain).

Modified:
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseInterceptorChain.java
    incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/logging/LogUtils.java
    incubator/cxf/trunk/common/common/src/test/java/org/apache/cxf/common/logging/LogUtilsTest.java

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseInterceptorChain.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseInterceptorChain.java?view=diff&rev=523605&r1=523604&r2=523605
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseInterceptorChain.java
(original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseInterceptorChain.java
Thu Mar 29 00:46:54 2007
@@ -178,8 +178,8 @@
                     }
  
                     faultOccured = true;
-                    if (LOG.isLoggable(Level.FINE)) {
-                        LogUtils.log(LOG, Level.FINE, "Interceptor has thrown exception,
unwinding now", ex);
+                    if (LOG.isLoggable(Level.INFO)) {
+                        LogUtils.log(LOG, Level.INFO, "Interceptor has thrown exception,
unwinding now", ex);
                     }
                     message.setContent(Exception.class, ex);
                     if (message.getExchange() != null) {

Modified: incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/logging/LogUtils.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/logging/LogUtils.java?view=diff&rev=523605&r1=523604&r2=523605
==============================================================================
--- incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/logging/LogUtils.java
(original)
+++ incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/logging/LogUtils.java
Thu Mar 29 00:46:54 2007
@@ -120,7 +120,22 @@
             doLog(logger, level, formattedMessage, null);
         }
         
-    }    
+    }  
+    
+    /**
+     * Checks log level and logs
+     *
+     * @param logger the Logger the log to
+     * @param level the severity level
+     * @param message the log message
+     * @param throwable the Throwable to log
+     */      
+    public static void log(Logger logger, 
+                           Level level, 
+                           String message, 
+                           Throwable throwable) {
+        log(logger, level, message, throwable, NO_PARAMETERS);
+    }
   
     /**
      * Checks log level and logs

Modified: incubator/cxf/trunk/common/common/src/test/java/org/apache/cxf/common/logging/LogUtilsTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/common/common/src/test/java/org/apache/cxf/common/logging/LogUtilsTest.java?view=diff&rev=523605&r1=523604&r2=523605
==============================================================================
--- incubator/cxf/trunk/common/common/src/test/java/org/apache/cxf/common/logging/LogUtilsTest.java
(original)
+++ incubator/cxf/trunk/common/common/src/test/java/org/apache/cxf/common/logging/LogUtilsTest.java
Thu Mar 29 00:46:54 2007
@@ -62,6 +62,36 @@
         EasyMock.verify(handler);
         LOG.removeHandler(handler);
     }
+    
+    @Test
+    public void testLogNoParamsOrThrowable() {
+        Handler handler = EasyMock.createNiceMock(Handler.class);
+        LOG.addHandler(handler);
+        // handler called *after* localization of message
+        LogRecord record = new LogRecord(Level.SEVERE, "subbed in {0} only");
+        EasyMock.reportMatcher(new LogRecordMatcher(record));
+        handler.publish(record);
+        EasyMock.replay(handler);
+        LogUtils.log(LOG, Level.SEVERE, "SUB1_MSG");
+        EasyMock.verify(handler);
+        LOG.removeHandler(handler);
+    }
+    
+    @Test
+    public void testLogNoParamsWithThrowable() {
+        Handler handler = EasyMock.createNiceMock(Handler.class);
+        LOG.addHandler(handler);
+        // handler called *after* localization of message
+        Exception ex = new Exception("x");
+        LogRecord record = new LogRecord(Level.SEVERE, "subbed in {0} only");
+        record.setThrown(ex);
+        EasyMock.reportMatcher(new LogRecordMatcher(record));
+        handler.publish(record);
+        EasyMock.replay(handler);
+        LogUtils.log(LOG, Level.SEVERE, "SUB1_MSG", ex);
+        EasyMock.verify(handler);
+        LOG.removeHandler(handler);
+    }
 
     @Test
     public void testLogParamSubstitutionWithThrowable() throws Exception {



Mime
View raw message