Author: henning
Date: Sat Sep 16 03:26:13 2006
New Revision: 446843

URL: http://svn.apache.org/viewvc?view=rev&rev=446843
Log:
Clean up the trace logging, removing an inconsistent synchronized()
access on the way. Suggested by FindBugs.

Modified:
    
jakarta/velocity/engine/trunk/src/java/org/apache/velocity/runtime/VelocimacroFactory.java

Modified: 
jakarta/velocity/engine/trunk/src/java/org/apache/velocity/runtime/VelocimacroFactory.java
URL: 
http://svn.apache.org/viewvc/jakarta/velocity/engine/trunk/src/java/org/apache/velocity/runtime/VelocimacroFactory.java?view=diff&rev=446843&r1=446842&r2=446843
==============================================================================
--- 
jakarta/velocity/engine/trunk/src/java/org/apache/velocity/runtime/VelocimacroFactory.java
 (original)
+++ 
jakarta/velocity/engine/trunk/src/java/org/apache/velocity/runtime/VelocimacroFactory.java
 Sat Sep 16 03:26:13 2006
@@ -117,18 +117,16 @@
     public void initVelocimacro()
     {
         /*
+         *  respect message switch even from the start
+         */
+        outputMessages = rsvc.getBoolean(RuntimeConstants.VM_MESSAGES_ON, 
true);
+
+        /*
          *  maybe I'm just paranoid...
          */
         synchronized( this )
         {
-            /*
-             *  respect message switch even from the start
-             */
-            outputMessages = rsvc.getBoolean(RuntimeConstants.VM_MESSAGES_ON, 
true);
-            if (outputMessages && log.isTraceEnabled())
-            {
-                log.trace("Velocimacro : initialization starting.");
-            }
+            trace("Velocimacro : initialization starting.");
 
             /*
              *   allow replacements while we add the libraries, if exist
@@ -214,13 +212,10 @@
                          } 
                          catch (Exception e)
                          {
-                             log.error("Velocimacro : Error using VM library : 
"+lib, e);
+                             log.error("Velocimacro : Error using VM library : 
" + lib, e);
                          }
 
-                         if (outputMessages && log.isTraceEnabled())
-                         {
-                             log.trace("Velocimacro : VM library registration 
complete.");
-                         }
+                         trace("Velocimacro : VM library registration 
complete.");
             
                          vmManager.setRegisterFromLib( false );
                      }
@@ -314,10 +309,7 @@
                       "will not automatically reload global library macros");
             }
 
-            if (outputMessages && log.isTraceEnabled())
-            {
-                log.trace("Velocimacro : initialization complete.");
-            }
+            trace("Velocimacro : initialization complete.");
         }
     
         return;
@@ -362,13 +354,10 @@
         /*
          * Report addition of the new Velocimacro.
          */
-        if (outputMessages && log.isInfoEnabled())
-        {
-            StringBuffer msg = new StringBuffer("Velocimacro : added ");
-            Macro.macroToString(msg, argArray);
-            msg.append(" : source = ").append(sourceTemplate);
-            log.info(msg);
-        }
+        StringBuffer msg = new StringBuffer("Velocimacro : added ");
+        Macro.macroToString(msg, argArray);
+        msg.append(" : source = ").append(sourceTemplate);
+        info(msg.toString());
 
         return true;
     }
@@ -473,6 +462,17 @@
         }
     }
       
+    /**
+     *  localization of the logging logic
+     */
+    private void trace(String s)
+    {
+        if (outputMessages && log.isTraceEnabled())
+        {
+            log.trace("Velocimacro : " + s);
+        }
+    }
+
     /**
      *  Tells the world if a given directive string is a Velocimacro
      */



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to