db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r1626585 - /db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/controller/Log4jLoggingAdapter.java
Date Sun, 21 Sep 2014 14:46:01 GMT
Author: tfischer
Date: Sun Sep 21 14:46:01 2014
New Revision: 1626585

URL: http://svn.apache.org/r1626585
Log:
fix findbugs bug: Initialization circularity between org.apache.torque.generator.configuration.controller.Log4jLoggingAdapter
and org.apache.torque.generator.configuration.controller.Loglevel

Modified:
    db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/controller/Log4jLoggingAdapter.java

Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/controller/Log4jLoggingAdapter.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/controller/Log4jLoggingAdapter.java?rev=1626585&r1=1626584&r2=1626585&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/controller/Log4jLoggingAdapter.java
(original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/generator/configuration/controller/Log4jLoggingAdapter.java
Sun Sep 21 14:46:01 2014
@@ -39,17 +39,17 @@ public class Log4jLoggingAdapter impleme
     private static Log log = LogFactory.getLog(Log4jLoggingAdapter.class);
 
     /** Map loglevel -> corresponding log4j level. */
-    private static final Map<Loglevel, Level> LOG4J_LEVELS;
+    private final Map<Loglevel, Level> log4jLevels;
 
-    static
+    public Log4jLoggingAdapter()
     {
-        Map<Loglevel, Level> log4jLevels = new HashMap<Loglevel, Level>();
-        log4jLevels.put(Loglevel.TRACE, Level.TRACE);
-        log4jLevels.put(Loglevel.DEBUG, Level.DEBUG);
-        log4jLevels.put(Loglevel.INFO, Level.INFO);
-        log4jLevels.put(Loglevel.WARN, Level.WARN);
-        log4jLevels.put(Loglevel.ERROR, Level.ERROR);
-        LOG4J_LEVELS = Collections.unmodifiableMap(log4jLevels);
+        Map<Loglevel, Level> levels = new HashMap<Loglevel, Level>();
+        levels.put(Loglevel.TRACE, Level.TRACE);
+        levels.put(Loglevel.DEBUG, Level.DEBUG);
+        levels.put(Loglevel.INFO, Level.INFO);
+        levels.put(Loglevel.WARN, Level.WARN);
+        levels.put(Loglevel.ERROR, Level.ERROR);
+        log4jLevels = Collections.unmodifiableMap(levels);
     }
 
     /**
@@ -61,7 +61,7 @@ public class Log4jLoggingAdapter impleme
     public Loglevel getCurrentLoglevel()
     {
         Level level = Logger.getRootLogger().getLevel();
-        for (Map.Entry<Loglevel, Level> loglevel : LOG4J_LEVELS.entrySet())
+        for (Map.Entry<Loglevel, Level> loglevel : log4jLevels.entrySet())
         {
             if (loglevel.getValue().equals(level))
             {
@@ -77,18 +77,17 @@ public class Log4jLoggingAdapter impleme
      *
      *  @param loglevel the loglevel to set, not null.
      */
-    public void setLoglevel(Loglevel loglevel)
+    public void setLoglevel(final Loglevel loglevel)
     {
         if (loglevel == null)
         {
             return;
         }
-        Level log4jLevel = LOG4J_LEVELS.get(loglevel);
-        if (Logger.getRootLogger().getLevel() != LOG4J_LEVELS.get(loglevel))
+        Level log4jLevel = log4jLevels.get(loglevel);
+        if (Logger.getRootLogger().getLevel() != log4jLevels.get(loglevel))
         {
             log.info("apply() : Setting loglevel to " + loglevel);
             Logger.getRootLogger().setLevel(log4jLevel);
         }
     }
-
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message