You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by ma...@apache.org on 2014/03/23 22:58:43 UTC

svn commit: r1580630 - /logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/status/StatusConsoleListener.java

Author: mattsicker
Date: Sun Mar 23 21:58:42 2014
New Revision: 1580630

URL: http://svn.apache.org/r1580630
Log:
Reduce redundancy in StatusConsoleListener constructors.

Modified:
    logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/status/StatusConsoleListener.java

Modified: logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/status/StatusConsoleListener.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/status/StatusConsoleListener.java?rev=1580630&r1=1580629&r2=1580630&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/status/StatusConsoleListener.java (original)
+++ logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/status/StatusConsoleListener.java Sun Mar 23 21:58:42 2014
@@ -24,6 +24,7 @@ import org.apache.logging.log4j.util.Pro
 /**
  * StatusListener that writes to the Console.
  */
+@SuppressWarnings("UseOfSystemOutOrSystemErr")
 public class StatusConsoleListener implements StatusListener {
 
     private static final String STATUS_LEVEL = "org.apache.logging.log4j.StatusLevel";
@@ -36,15 +37,11 @@ public class StatusConsoleListener imple
 
     /**
      * Creates the StatusConsoleListener using either the level configured by the
-     * "org.apache.logging.log4j.StatusLevel" system property if it is set or to a
+     * {@value #STATUS_LEVEL} system property if it is set or to a
      * default value of FATAL.
      */
     public StatusConsoleListener() {
-        final String str = PropertiesUtil.getProperties().getStringProperty(STATUS_LEVEL);
-        if (str != null) {
-            level = Level.toLevel(str, Level.FATAL);
-        }
-        stream = System.out;
+        this(Level.toLevel(PropertiesUtil.getProperties().getStringProperty(STATUS_LEVEL), Level.FATAL));
     }
 
     /**
@@ -52,12 +49,12 @@ public class StatusConsoleListener imple
      * @param level The Level of status messages that should appear on the console.
      */
     public StatusConsoleListener(final Level level) {
-        this.level = level;
-        stream = System.out;
+        this(level, System.out);
     }
 
     /**
-     * Creates the StatusConsoleListener using the supplied Level.
+     * Creates the StatusConsoleListener using the supplied Level. Make sure not to use a logger stream of some sort
+     * to avoid creating an infinite loop of indirection!
      * @param level The Level of status messages that should appear on the console.
      * @param stream The PrintStream to write to.
      */