logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1342906 - /logging/log4j/trunk/src/main/java/org/apache/log4j/Level.java
Date Sat, 26 May 2012 15:12:39 GMT
Author: ggregory
Date: Sat May 26 15:12:39 2012
New Revision: 1342906

URL: http://svn.apache.org/viewvc?rev=1342906&view=rev
Log:
Use constants instead of magic strings.

Modified:
    logging/log4j/trunk/src/main/java/org/apache/log4j/Level.java

Modified: logging/log4j/trunk/src/main/java/org/apache/log4j/Level.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/main/java/org/apache/log4j/Level.java?rev=1342906&r1=1342905&r2=1342906&view=diff
==============================================================================
--- logging/log4j/trunk/src/main/java/org/apache/log4j/Level.java (original)
+++ logging/log4j/trunk/src/main/java/org/apache/log4j/Level.java Sat May 26 15:12:39 2012
@@ -37,6 +37,22 @@ import java.io.Serializable;
  */
 public class Level extends Priority implements Serializable {
 
+    private static final String ALL_NAME = "ALL";
+
+    private static final String TRACE_NAME = "TRACE";
+
+    private static final String DEBUG_NAME = "DEBUG";
+
+    private static final String INFO_NAME = "INFO";
+
+    private static final String WARN_NAME = "WARN";
+
+    private static final String ERROR_NAME = "ERROR";
+
+    private static final String FATAL_NAME = "FATAL";
+
+    private static final String OFF_NAME = "OFF";
+
     /**
      * TRACE level integer value.
      * 
@@ -47,44 +63,44 @@ public class Level extends Priority impl
     /**
      * The <code>OFF</code> has the highest possible rank and is intended to
turn off logging.
      */
-    final static public Level OFF = new Level(OFF_INT, "OFF", 0);
+    final static public Level OFF = new Level(OFF_INT, OFF_NAME, 0);
 
     /**
      * The <code>FATAL</code> level designates very severe error events that
will presumably lead the application to abort.
      */
-    final static public Level FATAL = new Level(FATAL_INT, "FATAL", 0);
+    final static public Level FATAL = new Level(FATAL_INT, FATAL_NAME, 0);
 
     /**
      * The <code>ERROR</code> level designates error events that might still
allow the application to continue running.
      */
-    final static public Level ERROR = new Level(ERROR_INT, "ERROR", 3);
+    final static public Level ERROR = new Level(ERROR_INT, ERROR_NAME, 3);
 
     /**
      * The <code>WARN</code> level designates potentially harmful situations.
      */
-    final static public Level WARN = new Level(WARN_INT, "WARN", 4);
+    final static public Level WARN = new Level(WARN_INT, WARN_NAME, 4);
 
     /**
      * The <code>INFO</code> level designates informational messages that highlight
the progress of the application at coarse-grained level.
      */
-    final static public Level INFO = new Level(INFO_INT, "INFO", 6);
+    final static public Level INFO = new Level(INFO_INT, INFO_NAME, 6);
 
     /**
      * The <code>DEBUG</code> Level designates fine-grained informational events
that are most useful to debug an application.
      */
-    final static public Level DEBUG = new Level(DEBUG_INT, "DEBUG", 7);
+    final static public Level DEBUG = new Level(DEBUG_INT, DEBUG_NAME, 7);
 
     /**
      * The <code>TRACE</code> Level designates finer-grained informational events
than the <code>DEBUG</code level.
      * 
      * @since 1.2.12
      */
-    public static final Level TRACE = new Level(TRACE_INT, "TRACE", 7);
+    public static final Level TRACE = new Level(TRACE_INT, TRACE_NAME, 7);
 
     /**
      * The <code>ALL</code> has the lowest possible rank and is intended to turn
on all logging.
      */
-    final static public Level ALL = new Level(ALL_INT, "ALL", 7);
+    final static public Level ALL = new Level(ALL_INT, ALL_NAME, 7);
 
     /**
      * Serialization version id.
@@ -148,28 +164,28 @@ public class Level extends Priority impl
         }
         String s = sArg.toUpperCase();
 
-        if (s.equals("ALL")) {
+        if (s.equals(ALL_NAME)) {
             return Level.ALL;
         }
-        if (s.equals("DEBUG")) {
+        if (s.equals(DEBUG_NAME)) {
             return Level.DEBUG;
         }
-        if (s.equals("INFO")) {
+        if (s.equals(INFO_NAME)) {
             return Level.INFO;
         }
-        if (s.equals("WARN")) {
+        if (s.equals(WARN_NAME)) {
             return Level.WARN;
         }
-        if (s.equals("ERROR")) {
+        if (s.equals(ERROR_NAME)) {
             return Level.ERROR;
         }
-        if (s.equals("FATAL")) {
+        if (s.equals(FATAL_NAME)) {
             return Level.FATAL;
         }
-        if (s.equals("OFF")) {
+        if (s.equals(OFF_NAME)) {
             return Level.OFF;
         }
-        if (s.equals("TRACE")) {
+        if (s.equals(TRACE_NAME)) {
             return Level.TRACE;
         }
         //



Mime
View raw message