Author: cbrisson
Date: Fri Nov 11 20:17:14 2016
New Revision: 1769338
URL: http://svn.apache.org/viewvc?rev=1769338&view=rev
Log:
[engine] still logging reeng
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/Template.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/ParserPoolImpl.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/directive/Foreach.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Include.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Macro.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Parse.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/RuntimeMacro.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ContentResource.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/Resource.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceCacheImpl.java
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/Template.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/Template.java?rev=1769338&r1=1769337&r2=1769338&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/Template.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/Template.java
Fri Nov 11 20:17:14 2016
@@ -33,6 +33,7 @@ import org.apache.velocity.runtime.parse
import org.apache.velocity.runtime.parser.node.SimpleNode;
import org.apache.velocity.runtime.resource.Resource;
import org.apache.velocity.runtime.resource.ResourceManager;
+import org.slf4j.Logger;
import java.io.BufferedReader;
import java.io.IOException;
@@ -324,7 +325,7 @@ public class Template extends Resource
/*
* the macro lib wasn't found. Note it and throw
*/
- rsvc.getLog().error("template.merge(): " +
+ log.error("template.merge(): " +
"cannot find template " +
(String) macroLibraries.get(i));
throw re;
@@ -335,9 +336,9 @@ public class Template extends Resource
* the macro lib was found, but didn't parse - syntax
error
* note it and throw
*/
- rsvc.getLog().error("template.merge(): " +
+ rsvc.getLog("parser").error("template.merge(): " +
"syntax error in template " +
- (String) macroLibraries.get(i) + ".");
+ (String) macroLibraries.get(i) + ": {}",
pe.getMessage(), pe);
throw pe;
}
@@ -366,9 +367,13 @@ public class Template extends Resource
{
throw stop;
}
- else if (rsvc.getLog().isDebugEnabled())
+ else
{
- rsvc.getLog().debug(stop.getMessage());
+ Logger renderingLog = rsvc.getLog("rendering");
+ if (renderingLog.isDebugEnabled())
+ {
+ renderingLog.debug(stop.getMessage());
+ }
}
}
catch (IOException e)
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/ParserPoolImpl.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/ParserPoolImpl.java?rev=1769338&r1=1769337&r2=1769338&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/ParserPoolImpl.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/ParserPoolImpl.java
Fri Nov 11 20:17:14 2016
@@ -22,6 +22,7 @@ package org.apache.velocity.runtime;
import org.apache.velocity.runtime.parser.CharStream;
import org.apache.velocity.runtime.parser.Parser;
import org.apache.velocity.util.SimplePool;
+import org.slf4j.Logger;
/**
* This wraps the original parser SimplePool class. It also handles
@@ -35,6 +36,7 @@ public class ParserPoolImpl implements P
SimplePool pool = null;
int max = RuntimeConstants.NUMBER_OF_PARSERS;
+ Logger log;
/**
* Create the underlying "pool".
@@ -42,6 +44,7 @@ public class ParserPoolImpl implements P
*/
public void initialize(RuntimeServices rsvc)
{
+ log = rsvc.getLog("parser");
max = rsvc.getInt(RuntimeConstants.PARSER_POOL_SIZE,
RuntimeConstants.NUMBER_OF_PARSERS);
pool = new SimplePool(max);
@@ -50,9 +53,9 @@ public class ParserPoolImpl implements P
pool.put(rsvc.createNewParser());
}
- if (rsvc.getLog().isDebugEnabled())
+ if (log.isDebugEnabled())
{
- rsvc.getLog().debug("Created '" + max + "' parsers.");
+ log.debug("Created '" + max + "' parsers.");
}
}
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=1769338&r1=1769337&r2=1769338&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 20:17:14 2016
@@ -1428,7 +1428,7 @@ public class RuntimeInstance implements
catch(Exception e)
{
String msg = "RuntimeInstance.render(): init exception for tag
= "+logTag;
- getLog().error(msg, e);
+ log.error(msg, e);
throw new VelocityException(msg, e);
}
@@ -1452,9 +1452,9 @@ public class RuntimeInstance implements
{
throw stop;
}
- else if (getLog().isDebugEnabled())
+ else if (log.isDebugEnabled())
{
- getLog().debug(stop.getMessage());
+ log.debug(stop.getMessage());
}
}
catch (IOException e)
@@ -1517,7 +1517,7 @@ public class RuntimeInstance implements
if (vmName == null || context == null || writer == null)
{
String msg = "RuntimeInstance.invokeVelocimacro() : invalid call :
vmName, context, and writer must not be null";
- getLog().error(msg);
+ log.error(msg);
throw new NullPointerException(msg);
}
@@ -1536,7 +1536,7 @@ public class RuntimeInstance implements
{
String msg = "RuntimeInstance.invokeVelocimacro() : VM '" + vmName
+ "' is not registered.";
- getLog().error(msg);
+ log.error(msg);
throw new VelocityException(msg);
}
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Foreach.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Foreach.java?rev=1769338&r1=1769337&r2=1769338&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Foreach.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Foreach.java
Fri Nov 11 20:17:14 2016
@@ -187,7 +187,7 @@ public class Foreach extends Directive
{
String msg = "Error getting iterator for #foreach parameter "
+ node.literal() + " at " +
StringUtils.formatFileString(node);
- rsvc.getLog().error(msg, ee);
+ log.error(msg, ee);
throw new VelocityException(msg, ee);
}
@@ -196,7 +196,7 @@ public class Foreach extends Directive
String msg = "#foreach parameter " + node.literal() + " at "
+ StringUtils.formatFileString(node) + " is of type " +
iterable.getClass().getName()
+ " and cannot be iterated by " +
rsvc.getUberspect().getClass().getName();
- rsvc.getLog().error(msg);
+ log.error(msg);
throw new VelocityException(msg);
}
}
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Include.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Include.java?rev=1769338&r1=1769337&r2=1769338&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Include.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Include.java
Fri Nov 11 20:17:14 2016
@@ -169,7 +169,7 @@ public class Include extends InputBase
{
String msg = "invalid #include() argument '"
+ n.toString() + "' at " +
StringUtils.formatFileString(this);
- rsvc.getLog().error(msg);
+ log.error(msg);
outputErrorToStream( writer, "error with arg " + i
+ " please see log.");
throw new VelocityException(msg);
@@ -197,7 +197,7 @@ public class Include extends InputBase
{
if ( node == null )
{
- rsvc.getLog().error("#include() null argument");
+ log.error("#include() null argument");
return false;
}
@@ -207,7 +207,7 @@ public class Include extends InputBase
Object value = node.value( context );
if ( value == null)
{
- rsvc.getLog().error("#include() null argument");
+ log.error("#include() null argument");
return false;
}
@@ -242,7 +242,7 @@ public class Include extends InputBase
/*
* the arg wasn't found. Note it and throw
*/
- rsvc.getLog().error("#include(): cannot find resource '" + arg +
+ log.error("#include(): cannot find resource '" + arg +
"', called at " +
StringUtils.formatFileString(this));
throw rnfe;
}
@@ -252,7 +252,7 @@ public class Include extends InputBase
*/
catch( RuntimeException e )
{
- rsvc.getLog().error("#include(): arg = '" + arg +
+ log.error("#include(): arg = '" + arg +
"', called at " +
StringUtils.formatFileString(this));
throw e;
}
@@ -260,7 +260,7 @@ public class Include extends InputBase
{
String msg = "#include(): arg = '" + arg +
"', called at " + StringUtils.formatFileString(this);
- rsvc.getLog().error(msg, e);
+ log.error(msg, e);
throw new VelocityException(msg, e);
}
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Macro.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Macro.java?rev=1769338&r1=1769337&r2=1769338&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Macro.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Macro.java
Fri Nov 11 20:17:14 2016
@@ -231,8 +231,7 @@ public class Macro extends Directive
StringBuffer msg = new StringBuffer("Macro.getArgArray() :
nbrArgs=");
msg.append(numArgs).append(" : ");
macroToString(msg, macroArgs);
- rsvc.getLog().debug(msg.toString());
- System.out.println("---- > macro: " + msg);
+ rsvc.getLog("macro").debug(msg.toString());
}
return macroArgs;
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Parse.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Parse.java?rev=1769338&r1=1769337&r2=1769338&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Parse.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Parse.java
Fri Nov 11 20:17:14 2016
@@ -149,9 +149,9 @@ public class Parse extends InputBase
* does it have a value? If you have a null reference, then no.
*/
Object value = node.jjtGetChild(0).value( context );
- if (value == null && rsvc.getLog().isDebugEnabled())
+ if (value == null && log.isDebugEnabled())
{
- rsvc.getLog().debug("#parse(): null argument at " +
+ log.debug("#parse(): null argument at " +
StringUtils.formatFileString(this));
}
@@ -198,7 +198,7 @@ public class Parse extends InputBase
{
path.append( " > " + templateStack[i] );
}
- rsvc.getLog().error("Max recursion depth reached (" +
+ log.error("Max recursion depth reached (" +
templateStack.length + ')' + " File
stack:" +
path);
return false;
@@ -220,7 +220,7 @@ public class Parse extends InputBase
/*
* the arg wasn't found. Note it and throw
*/
- rsvc.getLog().error("#parse(): cannot find template '" + arg +
+ log.error("#parse(): cannot find template '" + arg +
"', called at " +
StringUtils.formatFileString(this));
throw rnfe;
}
@@ -230,7 +230,7 @@ public class Parse extends InputBase
* the arg was found, but didn't parse - syntax error
* note it and throw
*/
- rsvc.getLog().error("#parse(): syntax error in #parse()-ed
template '"
+ log.error("#parse(): syntax error in #parse()-ed template '"
+ arg + "', called at " +
StringUtils.formatFileString(this));
throw pee;
}
@@ -239,7 +239,7 @@ public class Parse extends InputBase
*/
catch( RuntimeException e )
{
- rsvc.getLog().error("Exception rendering #parse(" + arg + ") at " +
+ log.error("Exception rendering #parse(" + arg + ") at " +
StringUtils.formatFileString(this));
throw e;
}
@@ -247,7 +247,7 @@ public class Parse extends InputBase
{
String msg = "Exception rendering #parse(" + arg + ") at " +
StringUtils.formatFileString(this);
- rsvc.getLog().error(msg, e);
+ log.error(msg, e);
throw new VelocityException(msg, e);
}
@@ -294,7 +294,7 @@ public class Parse extends InputBase
/**
* Log #parse errors so the user can track which file called which.
*/
- rsvc.getLog().error("Exception rendering #parse(" + arg + ") at " +
+ log.error("Exception rendering #parse(" + arg + ") at " +
StringUtils.formatFileString(this));
throw e;
}
@@ -302,7 +302,7 @@ public class Parse extends InputBase
{
String msg = "Exception rendering #parse(" + arg + ") at " +
StringUtils.formatFileString(this);
- rsvc.getLog().error(msg, e);
+ log.error(msg, e);
throw new VelocityException(msg, e);
}
finally
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/RuntimeMacro.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/RuntimeMacro.java?rev=1769338&r1=1769337&r2=1769338&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/RuntimeMacro.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/RuntimeMacro.java
Fri Nov 11 20:17:14 2016
@@ -342,13 +342,13 @@ public class RuntimeMacro extends Direct
* especially important for multiple macro call levels.
* this is also true for the following catch blocks.
*/
- rsvc.getLog().error("Exception in macro #" + macroName + "
called at " +
+ log.error("Exception in macro #" + macroName + " called at " +
StringUtils.formatFileString(node));
throw e;
}
catch (IOException e)
{
- rsvc.getLog().error("Exception in macro #" + macroName + "
called at " +
+ log.error("Exception in macro #" + macroName + " called at " +
StringUtils.formatFileString(node));
throw e;
}
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java?rev=1769338&r1=1769337&r2=1769338&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java
Fri Nov 11 20:17:14 2016
@@ -137,7 +137,8 @@ public class VelocimacroProxy extends Di
*/
public void init(RuntimeServices rs)
{
- rsvc = rs; // CB TODO - why not super.init(rs) ?
+ rsvc = rs;
+ log = rs.getLog("macro");
// this is a very expensive call (ExtendedProperties is very slow)
strictArguments = rsvc.getConfiguration().getBoolean(
@@ -202,7 +203,7 @@ public class VelocimacroProxy extends Di
catch (Exception e)
{
String msg = "VelocimacroProxy.render() : exception VM = #" +
macroName + "()";
- rsvc.getLog().error(msg, e);
+ log.error(msg, e);
throw new VelocityException(msg, e);
}
finally
@@ -256,10 +257,10 @@ public class VelocimacroProxy extends Di
+ macroArgs.get(0).name + " accepts at most " +
(macroArgs.size()-1)
+ " at " + StringUtils.formatFileString(node));
}
- else if (rsvc.getLog().isDebugEnabled())
+ else if (log.isDebugEnabled())
{
// Backward compatibility logging, Mainly for
MacroForwardDefinedTestCase
- rsvc.getLog().debug("VM #" + macroArgs.get(0).name
+ log.debug("VM #" + macroArgs.get(0).name
+ ": too many arguments to macro. Wanted " +
(macroArgs.size()-1)
+ " got " + callArgNum);
}
@@ -289,7 +290,7 @@ public class VelocimacroProxy extends Di
out.append(stack[i]);
}
out.append(" at " + StringUtils.formatFileString(this));
- rsvc.getLog().error(out.toString());
+ log.error(out.toString());
// clean out the macro stack, since we just broke it
while (context.getCurrentMacroCallDepth() > 0)
@@ -346,9 +347,9 @@ public class VelocimacroProxy extends Di
else
{
// Backward compatibility logging, Mainly for
MacroForwardDefinedTestCase
- if (rsvc.getLog().isDebugEnabled())
+ if (log.isDebugEnabled())
{
- rsvc.getLog().debug("VM #" + macroArgs.get(0).name
+ log.debug("VM #" + macroArgs.get(0).name
+ ": too few arguments to macro. Wanted " +
(macroArgs.size()-1)
+ " got " + callArgNum);
}
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ContentResource.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ContentResource.java?rev=1769338&r1=1769337&r2=1769338&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ContentResource.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ContentResource.java
Fri Nov 11 20:17:14 2016
@@ -83,7 +83,7 @@ public class ContentResource extends Res
catch ( Exception e )
{
String msg = "Cannot process content resource";
- rsvc.getLog().error(msg, e);
+ log.error(msg, e);
throw new VelocityException(msg, e);
}
finally
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/Resource.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/Resource.java?rev=1769338&r1=1769337&r2=1769338&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/Resource.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/Resource.java
Fri Nov 11 20:17:14 2016
@@ -24,6 +24,7 @@ import org.apache.velocity.exception.Res
import org.apache.velocity.runtime.RuntimeConstants;
import org.apache.velocity.runtime.RuntimeServices;
import org.apache.velocity.runtime.resource.loader.ResourceLoader2;
+import org.slf4j.Logger;
/**
* This class represent a general text resource that
@@ -37,6 +38,7 @@ import org.apache.velocity.runtime.resou
public abstract class Resource
{
protected RuntimeServices rsvc = null;
+ protected Logger log = null;
/**
* The template loader that initially loaded the input
@@ -100,6 +102,7 @@ public abstract class Resource
public void setRuntimeServices( RuntimeServices rs )
{
rsvc = rs;
+ log = rsvc.getLog("loader");
}
/**
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceCacheImpl.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceCacheImpl.java?rev=1769338&r1=1769337&r2=1769338&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceCacheImpl.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/resource/ResourceCacheImpl.java
Fri Nov 11 20:17:14 2016
@@ -21,6 +21,7 @@ package org.apache.velocity.runtime.reso
import org.apache.velocity.runtime.RuntimeConstants;
import org.apache.velocity.runtime.RuntimeServices;
+import org.slf4j.Logger;
import java.util.Collections;
import java.util.Iterator;
@@ -95,6 +96,8 @@ public class ResourceCacheImpl implement
*/
protected RuntimeServices rsvc = null;
+ protected Logger log;
+
/**
* @see
org.apache.velocity.runtime.resource.ResourceCache#initialize(org.apache.velocity.runtime.RuntimeServices)
*/
@@ -112,8 +115,8 @@ public class ResourceCacheImpl implement
lruCache.putAll(cache);
cache = lruCache;
}
- rsvc.getLog().debug("ResourceCache: initialized ("+this.getClass()+")
with "+
- cache.getClass()+" cache map.");
+ rsvc.getLog().debug("initialized (" + this.getClass() + ") with " +
+ cache.getClass() + " cache map.");
}
/**