Author: cbrisson
Date: Fri Nov 11 19:19:49 2016
New Revision: 1769330

URL: http://svn.apache.org/viewvc?rev=1769330&view=rev
Log:
[engine] Review logging:

 - uses the base logger namespace 'org.apache.velocity' unless specified with 
runtime.log.name in the configuration
 - have the runtime instance log with this base namespace, and other modules 
log with children namespaces:
   x directive, and velocity.directive.[directivename]
   x parser
   x loader and loader.[loadername]
   x macro
   x rendering
 - get rid of UberspectLoggable interface
 - added new method RuntimeServices.getLog(childNamespace) (returns base + '.' 
+ childNamespace, or the log instance if provided by runtime.log.instance)


Removed:
    
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/UberspectLoggable.java
Modified:
    
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/implement/EscapeReference.java
    
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/implement/IncludeNotFound.java
    
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeConstants.java
    
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeInstance.java
    
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeServices.java
    
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/VelocimacroFactory.java
    
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Directive.java
    
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/SimpleNode.java
    
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceManagerImpl.java
    
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/JarHolder.java
    
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/JarResourceLoader.java
    
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/ResourceLoader2.java
    
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/DeprecatedCheckUberspector.java
    
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/SecureUberspector.java
    
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/UberspectImpl.java
    
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/UberspectPublicFields.java
    velocity/engine/trunk/velocity-engine-core/src/main/parser/Parser.jjt

Modified: 
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/implement/EscapeReference.java
URL: 
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/implement/EscapeReference.java?rev=1769330&r1=1769329&r2=1769330&view=diff
==============================================================================
--- 
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/implement/EscapeReference.java
 (original)
+++ 
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/implement/EscapeReference.java
 Fri Nov 11 19:19:49 2016
@@ -20,10 +20,14 @@ package org.apache.velocity.app.event.im
  */
 
 import org.apache.velocity.app.event.ReferenceInsertionEventHandler;
+import org.apache.velocity.runtime.RuntimeConstants;
 import org.apache.velocity.runtime.RuntimeServices;
 import org.apache.velocity.util.RuntimeServicesAware;
 import org.apache.velocity.util.StringUtils;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import java.util.regex.PatternSyntaxException;
 
 /**
@@ -58,6 +62,8 @@ public abstract class EscapeReference im
 
     private String matchRegExp = null;
 
+    protected Logger log;
+
     /**
      * Escape the given text.  Override this in a subclass to do the actual
      * escaping.
@@ -115,6 +121,7 @@ public abstract class EscapeReference im
     public void setRuntimeServices(RuntimeServices rs)
     {
         this.rs = rs;
+        log = rs.getLog("event");
 
         // Get the regular expression pattern.
         matchRegExp = 
StringUtils.nullTrim(rs.getConfiguration().getString(getMatchAttribute()));
@@ -132,8 +139,8 @@ public abstract class EscapeReference im
             }
             catch (PatternSyntaxException E)
             {
-                rs.getLog().error("Invalid regular expression '" + matchRegExp
-                                  + "'.  No escaping will be performed.", E);
+                log.error("Invalid regular expression '" + matchRegExp
+                        + "'.  No escaping will be performed.", E);
                 matchRegExp = null;
             }
         }

Modified: 
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/implement/IncludeNotFound.java
URL: 
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/implement/IncludeNotFound.java?rev=1769330&r1=1769329&r2=1769330&view=diff
==============================================================================
--- 
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/implement/IncludeNotFound.java
 (original)
+++ 
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/event/implement/IncludeNotFound.java
 Fri Nov 11 19:19:49 2016
@@ -21,11 +21,15 @@ package org.apache.velocity.app.event.im
 
 import org.apache.velocity.app.event.IncludeEventHandler;
 import org.apache.velocity.context.Context;
+import org.apache.velocity.runtime.RuntimeConstants;
 import org.apache.velocity.runtime.RuntimeServices;
 import org.apache.velocity.util.ContextAware;
 import org.apache.velocity.util.RuntimeServicesAware;
 import org.apache.velocity.util.StringUtils;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 /**
  * Simple event handler that checks to see if an included page is available.
  * If not, it includes a designated replacement page instead.
@@ -49,7 +53,7 @@ import org.apache.velocity.util.StringUt
  * @version $Id$
  * @since 1.5
  */
-public class IncludeNotFound implements 
IncludeEventHandler,RuntimeServicesAware,ContextAware {
+public class IncludeNotFound implements IncludeEventHandler, 
RuntimeServicesAware, ContextAware {
 
     private static final String DEFAULT_NOT_FOUND = "notfound.vm";
     private static final String PROPERTY_NOT_FOUND = 
"eventhandler.include.notfound";
@@ -57,6 +61,8 @@ public class IncludeNotFound implements
     String notfound;
     Context context;
 
+    protected Logger log;
+
     /**
      * Check to see if included file exists, and display "not found" page if it
      * doesn't. If "not found" page does not exist, log an error and return
@@ -89,7 +95,7 @@ public class IncludeNotFound implements
                 /**
                  * can't find not found, so display nothing
                  */
-                rs.getLog().error("Can't find include not found page: " + 
notfound);
+                log.error("Can't find include not found page: " + notfound);
                 return null;
             }
         }
@@ -104,6 +110,7 @@ public class IncludeNotFound implements
     public void setRuntimeServices(RuntimeServices rs)
     {
          this.rs = rs;
+         log = rs.getLog("event");
          notfound = StringUtils.nullTrim(rs.getString(PROPERTY_NOT_FOUND, 
DEFAULT_NOT_FOUND));
     }
 

Modified: 
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeConstants.java
URL: 
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeConstants.java?rev=1769330&r1=1769329&r2=1769330&view=diff
==============================================================================
--- 
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeConstants.java
 (original)
+++ 
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeConstants.java
 Fri Nov 11 19:19:49 2016
@@ -50,16 +50,6 @@ public interface RuntimeConstants
     /** externally provided logger name. */
     String RUNTIME_LOG_NAME = "runtime.log.name";
 
-    /**
-     * Properties referenced in the template are required to exist the object
-     */
-    String RUNTIME_REFERENCES_STRICT = "runtime.references.strict";
-    
-    /**
-     * Indicates we are going to use modified escape behavior in strict mode
-     */
-    String RUNTIME_REFERENCES_STRICT_ESCAPE = 
"runtime.references.strict.escape";
-
     /** Logging of invalid references. */
     String RUNTIME_LOG_REFERENCE_LOG_INVALID = 
"runtime.log.invalid.references";
 
@@ -230,7 +220,23 @@ public interface RuntimeConstants
      * @since 1.7
      */
     String VM_BODY_REFERENCE = "velocimacro.body.reference";
-    
+
+    /*
+     * ----------------------------------------------------------------------
+     * S T I C T   M O D E  B E H A V I O U R
+     * ----------------------------------------------------------------------
+     */
+
+    /**
+     * Properties referenced in the template are required to exist the object
+     */
+    String RUNTIME_REFERENCES_STRICT = "runtime.references.strict";
+
+    /**
+     * Indicates we are going to use modified escape behavior in strict mode
+     */
+    String RUNTIME_REFERENCES_STRICT_ESCAPE = 
"runtime.references.strict.escape";
+
     /*
      * ----------------------------------------------------------------------
      * G E N E R A L  R U N T I M E  C O N F I G U R A T I O N
@@ -302,6 +308,12 @@ public interface RuntimeConstants
     /** Default Runtime properties. */
     String DEFAULT_RUNTIME_DIRECTIVES = 
"org/apache/velocity/runtime/defaults/directive.properties";
 
+    /** externally provided logger name. */
+    String DEFAULT_RUNTIME_LOG_NAME = "org.apache.velocity";
+
+    /** token used to identify the loader internally. */
+    String RESOURCE_LOADER_IDENTIFIER = "_RESOURCE_LOADER_IDENTIFIER_";
+
     /**
      * The default number of parser instances to create. Configurable via the 
parameter named by the {@link #PARSER_POOL_SIZE}
      * constant.

Modified: 
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeInstance.java
URL: 
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeInstance.java?rev=1769330&r1=1769329&r2=1769330&view=diff
==============================================================================
--- 
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeInstance.java
 (original)
+++ 
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeInstance.java
 Fri Nov 11 19:19:49 2016
@@ -51,7 +51,6 @@ import org.apache.velocity.util.StringUt
 import org.apache.velocity.util.introspection.ChainableUberspector;
 import org.apache.velocity.util.introspection.LinkingUberspector;
 import org.apache.velocity.util.introspection.Uberspect;
-import org.apache.velocity.util.introspection.UberspectLoggable;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -109,9 +108,9 @@ public class RuntimeInstance implements
     private  VelocimacroFactory vmFactory = null;
 
     /**
-     * The Runtime logger.  The default instance is the "Velocity" logger.
+     * The Runtime logger.  The default instance is the "org.apache.velocity" 
logger.
      */
-    private Logger log = LoggerFactory.getLogger("Velocity");
+    private Logger log = LoggerFactory.getLogger(DEFAULT_RUNTIME_LOG_NAME);
 
     /**
      * The Runtime parser pool
@@ -328,7 +327,7 @@ public class RuntimeInstance implements
             }
             catch (Exception e)
             {
-                getLog().error("Could not auto-initialize Velocity", e);
+                log.error("Could not auto-initialize Velocity", e);
                 throw new RuntimeException("Velocity could not be 
initialized!", e);
             }
         }
@@ -398,11 +397,6 @@ public class RuntimeInstance implements
 
             Uberspect u = (Uberspect)o;
 
-            if (u instanceof UberspectLoggable)
-            {
-                ((UberspectLoggable)u).setLog(getLog());
-            }
-
             if (u instanceof RuntimeServicesAware)
             {
                 ((RuntimeServicesAware)u).setRuntimeServices(this);
@@ -1695,6 +1689,24 @@ public class RuntimeInstance implements
         return log;
     }
 
+    /**
+     * Get a logger for the specified child namespace.
+     * If a logger was configured using the runtime.log.instance configuration 
property, returns this instance.
+     * Otherwise, uses SLF4J LoggerFactory on baseNamespace + childNamespace.
+     * @param childNamespace
+     * @return
+     */
+    public Logger getLog(String childNamespace)
+    {
+        Logger log = 
(Logger)getProperty(RuntimeConstants.RUNTIME_LOG_INSTANCE);
+        if (log == null)
+        {
+            String loggerName = getString(RUNTIME_LOG_NAME, 
DEFAULT_RUNTIME_LOG_NAME) + "." + childNamespace;
+            log = LoggerFactory.getLogger(loggerName);
+        }
+        return log;
+    }
+
     /**
      * String property accessor method with default to hide the
      * configuration implementation.

Modified: 
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeServices.java
URL: 
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeServices.java?rev=1769330&r1=1769329&r2=1769330&view=diff
==============================================================================
--- 
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeServices.java
 (original)
+++ 
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeServices.java
 Fri Nov 11 19:19:49 2016
@@ -440,6 +440,15 @@ public interface RuntimeServices
     public Logger getLog();
 
     /**
+     * Get a logger for the specified child namespace.
+     * If a logger was configured using the runtime.log.instance configuration 
property, returns this instance.
+     * Otherwise, uses SLF4J LoggerFactory on baseNamespace + childNamespace.
+     * @param childNamespace
+     * @return
+     */
+    public Logger getLog(String childNamespace);
+
+    /**
      * Returns the event handlers for the application.
      * @return The event handlers for the application.
      */
@@ -465,7 +474,15 @@ public interface RuntimeServices
      */
     public Directive getDirective(String name);
 
+    /**
+     * Check whether the engine uses string interning
+     * @return true if string interning is active
+     */
     public boolean useStringInterning();
 
+    /**
+     * get space gobbling mode
+     * @return space gobbling mode
+     */
     public SpaceGobbling getSpaceGobbling();
 }

Modified: 
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/VelocimacroFactory.java
URL: 
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/VelocimacroFactory.java?rev=1769330&r1=1769329&r2=1769330&view=diff
==============================================================================
--- 
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/VelocimacroFactory.java
 (original)
+++ 
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/VelocimacroFactory.java
 Fri Nov 11 19:19:49 2016
@@ -26,7 +26,9 @@ import org.apache.velocity.runtime.direc
 import org.apache.velocity.runtime.directive.Macro;
 import org.apache.velocity.runtime.directive.VelocimacroProxy;
 import org.apache.velocity.runtime.parser.node.Node;
+
 import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -104,7 +106,7 @@ public class VelocimacroFactory
     public VelocimacroFactory(final RuntimeServices rsvc)
     {
         this.rsvc = rsvc;
-        this.log = rsvc.getLog();
+        this.log = rsvc.getLog("macro");
 
         /*
          *  we always access in a synchronized(), so we

Modified: 
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Directive.java
URL: 
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Directive.java?rev=1769330&r1=1769329&r2=1769330&view=diff
==============================================================================
--- 
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Directive.java
 (original)
+++ 
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Directive.java
 Fri Nov 11 19:19:49 2016
@@ -31,11 +31,13 @@ import org.apache.velocity.runtime.parse
 import org.apache.velocity.runtime.parser.Token;
 import org.apache.velocity.runtime.parser.node.Node;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import java.io.IOException;
 import java.io.Writer;
 import java.util.ArrayList;
 
-
 /**
  * Base class for all directives used in Velocity.
  *
@@ -50,6 +52,8 @@ public abstract class Directive implemen
     private boolean provideScope = false;
     private Template template;
 
+    protected Logger log = null;
+
     /**
      *
      */
@@ -155,6 +159,7 @@ public abstract class Directive implemen
         throws TemplateInitException
     {
         rsvc = rs;
+        log = rsvc.getLog("directive." + getName());
 
         String property = 
getScopeName()+'.'+RuntimeConstants.PROVIDE_SCOPE_CONTROL;
         this.provideScope = rsvc.getBoolean(property, provideScope);

Modified: 
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/SimpleNode.java
URL: 
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/SimpleNode.java?rev=1769330&r1=1769329&r2=1769330&view=diff
==============================================================================
--- 
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/SimpleNode.java
 (original)
+++ 
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/SimpleNode.java
 Fri Nov 11 19:19:49 2016
@@ -25,15 +25,17 @@ import org.apache.velocity.exception.Met
 import org.apache.velocity.exception.ParseErrorException;
 import org.apache.velocity.exception.ResourceNotFoundException;
 import org.apache.velocity.exception.TemplateInitException;
+import org.apache.velocity.runtime.RuntimeConstants;
 import org.apache.velocity.runtime.RuntimeServices;
 import org.apache.velocity.runtime.parser.Parser;
 import org.apache.velocity.runtime.parser.Token;
 import org.apache.velocity.util.StringUtils;
+
 import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
 import java.io.Writer;
-import java.util.Arrays;
 
 /**
  *
@@ -332,7 +334,7 @@ public class SimpleNode implements Node
          */
 
         rsvc = (RuntimeServices) data;
-        log = rsvc.getLog();
+        log = rsvc.getLog("rendering");
 
         int i, k = jjtGetNumChildren();
 

Modified: 
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceManagerImpl.java
URL: 
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceManagerImpl.java?rev=1769330&r1=1769329&r2=1769330&view=diff
==============================================================================
--- 
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceManagerImpl.java
 (original)
+++ 
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceManagerImpl.java
 Fri Nov 11 19:19:49 2016
@@ -30,6 +30,7 @@ import org.apache.velocity.util.ClassUti
 import org.apache.velocity.util.ExtProperties;
 import org.apache.velocity.util.StringUtils;
 import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.util.ArrayList;
 import java.util.Iterator;
@@ -57,9 +58,6 @@ public class ResourceManagerImpl
     /** A static content resource. */
     public static final int RESOURCE_CONTENT = 2;
 
-    /** token used to identify the loader internally. */
-    private static final String RESOURCE_LOADER_IDENTIFIER = 
"_RESOURCE_LOADER_IDENTIFIER_";
-
     /** Object implementing ResourceCache to be our resource manager's 
Resource cache. */
     protected ResourceCache globalCache = null;
 
@@ -93,7 +91,7 @@ public class ResourceManagerImpl
      *
      * @param  rsvc  The Runtime Services object which is associated with this 
Resource Manager.
      */
-    public synchronized void initialize(final RuntimeServices rsvc)
+    public synchronized void initialize(final RuntimeServices rs)
     {
         if (isInit)
         {
@@ -103,8 +101,8 @@ public class ResourceManagerImpl
 
         ResourceLoader2 resourceLoader = null;
 
-        this.rsvc = rsvc;
-        log = rsvc.getLog();
+        rsvc = rs;
+        log = rsvc.getLog("loader");
 
         log.trace("ResourceManager initializing: {}", this.getClass());
 
@@ -132,7 +130,7 @@ public class ResourceManagerImpl
             else
             {
                 String msg = "Unable to find '" +
-                          configuration.getString(RESOURCE_LOADER_IDENTIFIER) +
+                          
configuration.getString(RuntimeConstants.RESOURCE_LOADER_IDENTIFIER) +
                           ".resource.loader.class' specification in 
configuration." +
                           " This is a critical value.  Please adjust 
configuration.";
                 log.error(msg);
@@ -250,7 +248,7 @@ public class ResourceManagerImpl
              *  in the 'name' field
              */
 
-            loaderConfiguration.setProperty(RESOURCE_LOADER_IDENTIFIER, 
loaderName);
+            
loaderConfiguration.setProperty(RuntimeConstants.RESOURCE_LOADER_IDENTIFIER, 
loaderName);
 
             /*
              * Add resources to the list of resource loader

Modified: 
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/JarHolder.java
URL: 
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/JarHolder.java?rev=1769330&r1=1769329&r2=1769330&view=diff
==============================================================================
--- 
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/JarHolder.java
 (original)
+++ 
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/JarHolder.java
 Fri Nov 11 19:19:49 2016
@@ -23,6 +23,7 @@ import org.apache.velocity.exception.Res
 import org.apache.velocity.exception.VelocityException;
 import org.apache.velocity.runtime.RuntimeServices;
 import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
 import java.io.InputStream;
@@ -51,9 +52,9 @@ public class JarHolder
      * @param rs
      * @param urlpath
      */
-    public JarHolder( RuntimeServices rs, String urlpath )
+    public JarHolder( RuntimeServices rs, String urlpath, Logger log )
     {
-        this.log = rs.getLog();
+        this.log = log;
 
         this.urlpath=urlpath;
         init();

Modified: 
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/JarResourceLoader.java
URL: 
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/JarResourceLoader.java?rev=1769330&r1=1769329&r2=1769330&view=diff
==============================================================================
--- 
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/JarResourceLoader.java
 (original)
+++ 
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/JarResourceLoader.java
 Fri Nov 11 19:19:49 2016
@@ -137,7 +137,7 @@ public class JarResourceLoader extends R
         closeJar( path );
 
         // Create a new JarHolder
-        JarHolder temp = new JarHolder( rsvc,  path );
+        JarHolder temp = new JarHolder( rsvc,  path, log );
         // Add it's entries to the entryCollection
         addEntries(temp.getEntries());
         // Add it to the Jar table

Modified: 
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/ResourceLoader2.java
URL: 
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/ResourceLoader2.java?rev=1769330&r1=1769329&r2=1769330&view=diff
==============================================================================
--- 
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/ResourceLoader2.java
 (original)
+++ 
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/loader/ResourceLoader2.java
 Fri Nov 11 19:19:49 2016
@@ -27,7 +27,9 @@ import org.apache.velocity.runtime.Runti
 import org.apache.velocity.runtime.resource.Resource;
 import org.apache.velocity.runtime.resource.ResourceCacheImpl;
 import org.apache.velocity.util.ExtProperties;
+
 import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
 import java.io.InputStream;
@@ -78,7 +80,8 @@ public abstract class ResourceLoader2
     public void commonInit(RuntimeServices rs, ExtProperties configuration)
     {
         this.rsvc = rs;
-        this.log = rsvc.getLog();
+        String loaderName = 
configuration.getString(RuntimeConstants.RESOURCE_LOADER_IDENTIFIER);
+        log = rsvc.getLog("loader." + (loaderName == null ? 
this.getClass().getSimpleName() : loaderName));
 
         /*
          *  these two properties are not required for all loaders.

Modified: 
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/DeprecatedCheckUberspector.java
URL: 
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/DeprecatedCheckUberspector.java?rev=1769330&r1=1769329&r2=1769330&view=diff
==============================================================================
--- 
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/DeprecatedCheckUberspector.java
 (original)
+++ 
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/DeprecatedCheckUberspector.java
 Fri Nov 11 19:19:49 2016
@@ -33,7 +33,7 @@ import java.lang.reflect.Method;
  * @version $Id:$
  * @see ChainableUberspector
  */
-public class DeprecatedCheckUberspector extends AbstractChainableUberspector 
implements Uberspect, UberspectLoggable
+public class DeprecatedCheckUberspector extends AbstractChainableUberspector 
implements Uberspect
 {
     @Override
     public void init()

Modified: 
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/SecureUberspector.java
URL: 
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/SecureUberspector.java?rev=1769330&r1=1769329&r2=1769330&view=diff
==============================================================================
--- 
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/SecureUberspector.java
 (original)
+++ 
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/SecureUberspector.java
 Fri Nov 11 19:19:49 2016
@@ -40,15 +40,8 @@ import java.util.Iterator;
  * @version $Id$
  * @since 1.5
  */
-public class SecureUberspector extends UberspectImpl implements 
RuntimeServicesAware
+public class SecureUberspector extends UberspectImpl
 {
-    RuntimeServices runtimeServices;
-    
-    public SecureUberspector()
-    {
-        super();
-    }
-
     /**
      *  init - generates the Introspector. As the setup code
      *  makes sure that the log gets set before this is called,
@@ -56,10 +49,10 @@ public class SecureUberspector extends U
      */
     public void init()
     {
-        String [] badPackages = runtimeServices.getConfiguration()
+        String [] badPackages = rsvc.getConfiguration()
                         
.getStringArray(RuntimeConstants.INTROSPECTOR_RESTRICT_PACKAGES);
 
-        String [] badClasses = runtimeServices.getConfiguration()
+        String [] badClasses = rsvc.getConfiguration()
                         
.getStringArray(RuntimeConstants.INTROSPECTOR_RESTRICT_CLASSES);
         
         introspector = new SecureIntrospectorImpl(badClasses, badPackages, 
log);
@@ -89,15 +82,4 @@ public class SecureUberspector extends U
         }
         return null;
     }
-
-    /**
-     * Store the RuntimeServices before the object is initialized..
-     * @param rs RuntimeServices object for initialization
-     */
-    public void setRuntimeServices(RuntimeServices rs)
-    {
-        this.runtimeServices = rs;
-    }
-    
-    
 }

Modified: 
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/UberspectImpl.java
URL: 
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/UberspectImpl.java?rev=1769330&r1=1769329&r2=1769330&view=diff
==============================================================================
--- 
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/UberspectImpl.java
 (original)
+++ 
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/UberspectImpl.java
 Fri Nov 11 19:19:49 2016
@@ -38,6 +38,7 @@ import org.apache.velocity.util.ClassUti
 import org.apache.velocity.util.EnumerationIterator;
 import org.apache.velocity.util.RuntimeServicesAware;
 import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.lang.reflect.Array;
 import java.lang.reflect.InvocationTargetException;
@@ -54,7 +55,7 @@ import java.util.Map;
  * @author <a href="mailto:henn...@apache.org";>Henning P. Schmiedehausen</a>
  * @version $Id$
  */
-public class UberspectImpl implements Uberspect, UberspectLoggable, 
RuntimeServicesAware
+public class UberspectImpl implements Uberspect, RuntimeServicesAware
 {
     /**
      *  Our runtime logger.
@@ -72,6 +73,11 @@ public class UberspectImpl implements Ub
     protected ConversionHandler conversionHandler;
 
     /**
+     * runtime services
+     */
+    protected RuntimeServices rsvc;
+
+    /**
      *  init - generates the Introspector. As the setup code
      *  makes sure that the log gets set before this is called,
      *  we can initialize the Introspector using the log object.
@@ -92,6 +98,9 @@ public class UberspectImpl implements Ub
      */
     public void setRuntimeServices(RuntimeServices rs)
     {
+        rsvc = rs;
+        log = rsvc.getLog("rendering");
+
         String conversionHandlerClass = 
rs.getString(RuntimeConstants.CONVERSION_HANDLER_CLASS);
         if (conversionHandlerClass == null || 
conversionHandlerClass.equals("none"))
         {
@@ -141,6 +150,7 @@ public class UberspectImpl implements Ub
      *
      * @param log The logger instance to use.
      * @since 1.5
+     * @Deprecated logger is now set by default to the namespace logger 
"velocity.rendering".
      */
     public void setLog(Logger log)
     {

Modified: 
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/UberspectPublicFields.java
URL: 
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/UberspectPublicFields.java?rev=1769330&r1=1769329&r2=1769330&view=diff
==============================================================================
--- 
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/UberspectPublicFields.java
 (original)
+++ 
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/UberspectPublicFields.java
 Fri Nov 11 19:19:49 2016
@@ -19,8 +19,10 @@
 
 package org.apache.velocity.util.introspection;
 
+import org.apache.velocity.runtime.RuntimeServices;
 import org.apache.velocity.runtime.parser.node.PublicFieldExecutor;
 import org.apache.velocity.runtime.parser.node.SetPublicFieldExecutor;
+import org.apache.velocity.util.RuntimeServicesAware;
 import org.apache.velocity.util.introspection.UberspectImpl.VelGetterImpl;
 import org.apache.velocity.util.introspection.UberspectImpl.VelSetterImpl;
 import org.slf4j.Logger;
@@ -34,7 +36,7 @@ import java.util.Iterator;
  * @author <a href="mailto:henn...@apache.org";>Henning P. Schmiedehausen</a>
  * @author <a href="mailto:cda...@cdauth.eu";>Candid Dauth</a>
  */
-public class UberspectPublicFields implements Uberspect, UberspectLoggable
+public class UberspectPublicFields implements Uberspect, RuntimeServicesAware
 {
     /**
      *  Our runtime logger.
@@ -57,18 +59,6 @@ public class UberspectPublicFields imple
     }
 
     /**
-     *  Sets the runtime logger - this must be called before anything
-     *  else.
-     *
-     * @param log The logger instance to use.
-     * @since 1.5
-     */
-    public void setLog(Logger log)
-    {
-        this.log = log;
-    }
-
-    /**
      * Property getter
      * @param obj
      * @param identifier
@@ -123,4 +113,8 @@ public class UberspectPublicFields imple
         return null;
     }
 
+    public void setRuntimeServices(RuntimeServices rs)
+    {
+        log = rs.getLog("rendering");
+    }
 }

Modified: velocity/engine/trunk/velocity-engine-core/src/main/parser/Parser.jjt
URL: 
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/parser/Parser.jjt?rev=1769330&r1=1769329&r2=1769330&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/src/main/parser/Parser.jjt 
(original)
+++ velocity/engine/trunk/velocity-engine-core/src/main/parser/Parser.jjt Fri 
Nov 11 19:19:49 2016
@@ -88,6 +88,8 @@ import org.apache.velocity.runtime.direc
 import org.apache.velocity.runtime.directive.MacroParseException;
 import org.apache.velocity.runtime.RuntimeConstants;
 
+import org.slf4j.Logger;
+
 /**
  * This class is responsible for parsing a Velocity
  * template. This class was generated by JavaCC using
@@ -124,6 +126,8 @@ public class Parser
 
     private RuntimeServices rsvc = null;
 
+    private Logger log = null;
+
     /**
      * This constructor was added to allow the re-use of parsers.
      * The normal constructor takes a single argument which
@@ -141,6 +145,13 @@ public class Parser
                 new ByteArrayInputStream("\n".getBytes()), 1, 1 ));
 
         /*
+         * then initialize logger
+         */
+
+         log = rs.getLog("parser");
+
+
+        /*
          * now setup a VCS for later use
          */
         velcharstream = new VelocityCharStream(
@@ -198,12 +209,12 @@ public class Parser
              *  thrown by the Macro class when something is amiss in the
              *  Macro specification
              */
-            rsvc.getLog().error("Parser Error: " + template.getName(), mee);
+            log.error("{}: {}", template.getName(), mee.getMessage(), mee);
             throw mee;
         }
         catch (ParseException pe)
         {
-            rsvc.getLog().error("Parser Exception: " + template.getName(), pe);
+            log.error("{}: {}", currentTemplate.getName(), pe.getMessage(), 
pe);
             throw new TemplateParseException (pe.currentToken,
                                pe.expectedTokenSequences, pe.tokenImage, 
currentTemplate.getName());
                }
@@ -213,8 +224,8 @@ public class Parser
         }
         catch (Exception e)
         {
-            String msg = "Parser Error: " + template.getName();
-            rsvc.getLog().error(msg, e);
+            String msg = template.getName() + ": " + e.getMessage();
+            log.error(msg, e);
             throw new VelocityException(msg, e);
         }
 


Reply via email to