commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r1471693 - /commons/sandbox/weaver/trunk/maven-plugin/src/main/java/org/apache/commons/weaver/maven/JavaLoggingToMojoLoggingRedirector.java
Date Wed, 24 Apr 2013 21:31:44 GMT
Author: mbenson
Date: Wed Apr 24 21:31:43 2013
New Revision: 1471693

URL: http://svn.apache.org/r1471693
Log:
some plexus Logger implementations, namely that used by m2eclipse, assume that a Throwable
argument is non-null

Modified:
    commons/sandbox/weaver/trunk/maven-plugin/src/main/java/org/apache/commons/weaver/maven/JavaLoggingToMojoLoggingRedirector.java

Modified: commons/sandbox/weaver/trunk/maven-plugin/src/main/java/org/apache/commons/weaver/maven/JavaLoggingToMojoLoggingRedirector.java
URL: http://svn.apache.org/viewvc/commons/sandbox/weaver/trunk/maven-plugin/src/main/java/org/apache/commons/weaver/maven/JavaLoggingToMojoLoggingRedirector.java?rev=1471693&r1=1471692&r2=1471693&view=diff
==============================================================================
--- commons/sandbox/weaver/trunk/maven-plugin/src/main/java/org/apache/commons/weaver/maven/JavaLoggingToMojoLoggingRedirector.java
(original)
+++ commons/sandbox/weaver/trunk/maven-plugin/src/main/java/org/apache/commons/weaver/maven/JavaLoggingToMojoLoggingRedirector.java
Wed Apr 24 21:31:43 2013
@@ -44,7 +44,8 @@ public class JavaLoggingToMojoLoggingRed
     private Log mojoLogger;
 
     /**
-     * @param mojoLogger the Maven mojo logger to delegate messages to.
+     * @param mojoLogger
+     *            the Maven mojo logger to delegate messages to.
      */
     public JavaLoggingToMojoLoggingRedirector(Log mojoLogger) {
         this.mojoLogger = mojoLogger;
@@ -77,7 +78,8 @@ public class JavaLoggingToMojoLoggingRed
     }
 
     /**
-     * deactivate the redirection and put the original Handlers back in place again.
+     * deactivate the redirection and put the original Handlers back in place
+     * again.
      */
     public void deactivate() {
         Logger rootLogger = LogManager.getLogManager().getLogger("");
@@ -97,18 +99,32 @@ public class JavaLoggingToMojoLoggingRed
 
         @Override
         public void publish(LogRecord record) {
-            Throwable exception = record.getThrown();
-            Level level = record.getLevel();
+            final Throwable exception = record.getThrown();
+            final Level level = record.getLevel();
             if (level == Level.SEVERE && mojoLogger.isErrorEnabled()) {
-                mojoLogger.error(getMessage(record), exception);
+                if (exception == null) {
+                    mojoLogger.error(getMessage(record));
+                } else {
+                    mojoLogger.error(getMessage(record), exception);
+                }
             } else if (level == Level.WARNING && mojoLogger.isWarnEnabled()) {
-                mojoLogger.warn(getMessage(record), exception);
+                if (exception == null) {
+                    mojoLogger.warn(getMessage(record));
+                } else {
+                    mojoLogger.warn(getMessage(record), exception);
+                }
             } else if (level == Level.INFO && mojoLogger.isInfoEnabled()) {
-                mojoLogger.info(getMessage(record), exception);
-            } else if (level == Level.CONFIG && mojoLogger.isDebugEnabled()) {
-                mojoLogger.debug(getMessage(record), exception);
+                if (exception == null) {
+                    mojoLogger.info(getMessage(record));
+                } else {
+                    mojoLogger.info(getMessage(record), exception);
+                }
             } else if (mojoLogger.isDebugEnabled()) {
-                mojoLogger.debug(getMessage(record), exception);
+                if (exception == null) {
+                    mojoLogger.debug(getMessage(record));
+                } else {
+                    mojoLogger.debug(getMessage(record), exception);
+                }
             }
         }
 



Mime
View raw message