Author: cbrisson
Date: Mon Aug 31 21:06:34 2015
New Revision: 1700350
URL: http://svn.apache.org/r1700350
Log:
[engine] switch to slf4j logging facade
Added:
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/misc/TestLogger.java
- copied, changed from r1700349,
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/misc/TestLogChute.java
Removed:
velocity/engine/trunk/WHY_SIX_JARS.txt
velocity/engine/trunk/src/site/xdoc/jar-dependencies.xml
velocity/engine/trunk/velocity-engine-commons-logging/
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/log/
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ExternalLoggerTestCase.java
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/misc/TestLogChute.java
velocity/engine/trunk/velocity-engine-examples/src/etc/logger_example/
velocity/engine/trunk/velocity-engine-examples/src/main/java/org/apache/velocity/example/Log4jLoggerExample.java
velocity/engine/trunk/velocity-engine-examples/src/main/java/org/apache/velocity/example/LoggerExample.java
velocity/engine/trunk/velocity-engine-log4j/
velocity/engine/trunk/velocity-engine-servlet/
velocity/engine/trunk/velocity-engine-slf4j/
velocity/engine/trunk/velocity-engine-uberjar/
Modified:
velocity/engine/trunk/README.txt
velocity/engine/trunk/pom.xml
velocity/engine/trunk/src/site/site.xml
velocity/engine/trunk/src/site/xdoc/developer-guide.xml
velocity/engine/trunk/src/site/xdoc/stylesheets/project.xml
velocity/engine/trunk/src/site/xdoc/user-guide.xml
velocity/engine/trunk/src/site/xdoc/webapps.xml
velocity/engine/trunk/velocity-engine-assembly/pom.xml
velocity/engine/trunk/velocity-engine-assembly/src/main/assembly/all.xml
velocity/engine/trunk/velocity-engine-core/pom.xml
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/Velocity.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/VelocityEngine.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/exception/MethodInvocationException.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/exception/ParseErrorException.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/RuntimeSingleton.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/Block.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Break.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Define.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/MacroParseException.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/parser/TemplateParseException.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTComparisonNode.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTIndex.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTIntegerRange.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTReference.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTSetDirective.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTStringLiteral.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/AbstractExecutor.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/BooleanPropertyExecutor.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/GetExecutor.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/MapGetExecutor.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/MapSetExecutor.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/PropertyExecutor.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/PublicFieldExecutor.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/PutExecutor.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/SetExecutor.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/SetPropertyExecutor.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/SetPublicFieldExecutor.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/ResourceLoader.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/StringUtils.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/ClassFieldMap.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/ClassMap.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/Info.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/Introspector.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/IntrospectorBase.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/IntrospectorCacheImpl.java
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/util/introspection/SecureIntrospectorImpl.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/UberspectLoggable.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/resources/org/apache/velocity/runtime/defaults/velocity.properties
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/AbsoluteFileResourceLoaderTestCase.java
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/BaseTestCase.java
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ClassloaderChangeTestCase.java
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ClasspathResourceTestCase.java
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ContextSafetyTestCase.java
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/EncodingTestCase.java
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/EventHandlingTestCase.java
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/FilteredEventHandlingTestCase.java
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/IncludeEventHandlingTestCase.java
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/InlineScopeVMTestCase.java
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/Introspector2TestCase.java
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/MacroForwardDefineTestCase.java
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/MethodInvocationExceptionTestCase.java
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/MethodOverloadingTestCase.java
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/MultiLoaderTestCase.java
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/MultipleFileResourcePathTestCase.java
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ParseWithMacroLibsTestCase.java
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ParserTestCase.java
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ResourceExistsTestCase.java
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ResourceLoaderInstanceTestCase.java
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/StopDirectiveTestCase.java
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/StringResourceLoaderRepositoryTestCase.java
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/StringResourceLoaderTestCase.java
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/TemplateTestCase.java
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/TemplateTestSuite.java
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/URLResourceLoaderTimeoutTestCase.java
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/VMLibraryTestCase.java
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/VelocimacroTestCase.java
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/VelocityAppTestCase.java
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/issues/VelTools66TestCase.java
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/issues/Velocity537TestCase.java
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/issues/Velocity580TestCase.java
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/sql/DataSourceResourceLoaderTestCase.java
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/util/introspection/ChainedUberspectorsTestCase.java
velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/util/introspection/ClassMapTestCase.java
velocity/engine/trunk/velocity-engine-examples/src/etc/README.txt
velocity/engine/trunk/velocity-engine-examples/src/main/java/org/apache/velocity/example/EventExample.java
Modified: velocity/engine/trunk/README.txt
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/README.txt?rev=1700350&r1=1700349&r2=1700350&view=diff
==============================================================================
--- velocity/engine/trunk/README.txt (original)
+++ velocity/engine/trunk/README.txt Mon Aug 31 21:06:34 2015
@@ -39,30 +39,6 @@ Apache Velocity will run with any versio
Building from source requires Java version 1.4 (or greater) and ant
1.6 or greater.
-
-INCLUDED PRE-BUILT JARS
------------------------
-
-If you are using an offical Apache Velocity release distribution, you
-will find two pre-built jars in the top level directory.
-
-1) velocity-<version>.jar:
- This jar does not include any external dependencies needed by
- Velocity, such as the commons-collection classes, the Avalon
- Logkit, or Apache Jakarta ORO. We do this to allow you to use
- whatever version of collections, logkit, etc that you wish w/o
- fear of collision. These jars are included in the distribution,
- in the build/lib directory, or at the respective project sites.
-
-2) velocity-dep-<version>.jar:
- This jar includes all dependencies that were present in previous
- distribution jars. It is intended as a convenience to allow you
- to drop this distribution in place of existing 1.1 or 1.2-dep
- distributions.
-
-Please see the WHY_TWO_JARS.txt file for more information.
-
-
UPGRADING FROM EARLIER RELEASES
-------------------------------
Modified: velocity/engine/trunk/pom.xml
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/pom.xml?rev=1700350&r1=1700349&r2=1700350&view=diff
==============================================================================
--- velocity/engine/trunk/pom.xml (original)
+++ velocity/engine/trunk/pom.xml Mon Aug 31 21:06:34 2015
@@ -184,12 +184,7 @@
</issueManagement>
<modules>
<module>velocity-engine-core</module>
- <module>velocity-engine-log4j</module>
- <module>velocity-engine-commons-logging</module>
- <module>velocity-engine-servlet</module>
- <module>velocity-engine-slf4j</module>
<module>velocity-engine-examples</module>
- <module>velocity-engine-uberjar</module>
<module>velocity-engine-assembly</module>
</modules>
Modified: velocity/engine/trunk/src/site/site.xml
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/src/site/site.xml?rev=1700350&r1=1700349&r2=1700350&view=diff
==============================================================================
--- velocity/engine/trunk/src/site/site.xml (original)
+++ velocity/engine/trunk/src/site/site.xml Mon Aug 31 21:06:34 2015
@@ -85,7 +85,6 @@
<item name="Changes" href="changes-report.html"/>
<item name="Resolved Issues" href="jira-report.html"/>
<item name="Upgrading" href="upgrading.html"/>
- <item name="Dependencies" href="jar-dependencies.html"/>
<item name="Source Code Repository"
href="http://svn.apache.org/viewvc/velocity/engine/trunk/"/>
<item name="Building from Source" href="build.html"/>
<item name="Release Process" href="release.html"/>
Modified: velocity/engine/trunk/src/site/xdoc/developer-guide.xml
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/src/site/xdoc/developer-guide.xml?rev=1700350&r1=1700349&r2=1700350&view=diff
==============================================================================
--- velocity/engine/trunk/src/site/xdoc/developer-guide.xml (original)
+++ velocity/engine/trunk/src/site/xdoc/developer-guide.xml Mon Aug 31 21:06:34
2015
@@ -91,14 +91,6 @@
<li>
<a href="#Configuring_Logging">Configuring Logging</a>
- <ul>
- <li>
- <a href="#usinglog4jwithexistinglogger">Using Log4j With Existing
Logger</a>
- </li>
- <li>
- <a href="#simpleexampleofacustomlogger">Simple Example of a Custom
Logger</a>
- </li>
- </ul>
</li>
<li>
@@ -184,16 +176,10 @@ more detail on the various options.
<strong>Dependencies</strong>
<p>
-Velocity uses elements of the Java 2 API such as collections, and therefore
-building requires the Java 2 Standard Edition SDK (Software Development Kit).
-To run Velocity, the Java 2 Standard Edition RTE (Run Time Environment)
-is required (or you can use the SDK, of course).
+For compiling or at runtime, Velocity needs a Java runtime environment version
of 1.5 or more recent.
</p>
<p>
-Velocity also is dependent upon a few packages for general functionality. They
-are included in the <code>build/lib</code> directory for convenience, but
-the default build target (see above) does not include them. If you use the
-default build target, you must add the dependencies to your classpath.
+Velocity also is dependent upon a few packages for general functionality:
</p>
<ul>
@@ -206,17 +192,8 @@ default build target, you must add the d
<b>Jakarta Commons Lang</b></a> - required.
</li>
<li>
- <a href="http://excalibur.apache.org/logger.html">
- <b>Excalibur (ex-Avalon) Logkit</b></a> - optional, but very common.
- Needed if using the default file-based logging in Velocity.
+ <a href="http://www.slf4j.org"><b>SLF4J API</b></a> - required
</li>
-<li>
- <a href="http://jakarta.apache.org/oro/index.html"><b>Jakarta ORO</b></a>
- - optional. Needed when using the
- <code>org.apache.velocity.convert.WebMacro</code> template conversion
- utility or
<code>org.apache.velocity.app.event.implement.EscapeReference</code>
- ReferenceInsertionEventHandler.
- </li>
</ul>
@@ -258,11 +235,6 @@ Some great sources are:
Velocity application utility class.
</li>
<li>
- logger example: <code>examples/logger_example</code>: a simple example
- showing how to create a custom logging class and register it with
- Velocity to receive all log messages.
- </li>
- <li>
XML example: <code>examples/xmlapp_example</code>: a simple example
showing how to use JDOM to read and access XML document data from
within a Velocity template. It also includes a demonstration of
@@ -414,11 +386,11 @@ import org.apache.velocity.Template;
/*
* Configure the engine - as an example, we are using
- * ourselves as the logger - see logging examples
+ * a specific logger name
*/
Velocity.setProperty(
- Velocity.RUNTIME_LOG_LOGSYSTEM, this);
+ Velocity.RUNTIME_LOG_NAME, "mylog");
/*
* now initialize the engine
@@ -461,11 +433,11 @@ VelocityEngine ve = new VelocityEngine()
/*
* configure the engine. In this case, we are using
- * ourselves as a logger (see logging examples..)
+ * a specific named logger
*/
ve.setProperty(
- VelocityEngine.RUNTIME_LOG_LOGSYSTEM, this);
+ VelocityEngine.RUNTIME_LOG_NAME, "mylog");
/*
* initialize the engine
@@ -1531,30 +1503,19 @@ to the right of the '=' sign.
</p>
<p>
-<code>runtime.log = velocity.log</code><br/>
-Full path and name of log file for error, warning,
-and informational messages. The location, if not absolute, is
-relative to the 'current directory'.
+<code>runtime.log.instance = <i>Java Object instance</i></code><br/>
+Living Java instance, that must implement the interface org.slf4j.Logger.<br/>
+This property can only be set programmatically.
</p>
<p>
-<code>runtime.log.logsystem</code><br/>
-This property has no default value. It is used to give Velocity an
-instantiated instance of a logging class that supports the interface
-<code>org.apache.velocity.runtime.log.LogChute</code>, which allows
-the combination of Velocity log messages with your other application
-log messages. Please see the section
-<a href="#Configuring_Logging"><b>Configuring Logging</b></a>
+<code>runtime.log.name = <i>name</i></code><br/>
+This property has no default value, since the default logger will be
instanciated as the logger for the class org.apache.velocity.app.Velocity.
+See <a href="#Configuring_Logging"><b>Configuring Logging</b></a>
for more information.
</p>
<p>
-<code>runtime.log.logsystem.class =
-org.apache.velocity.runtime.log.AvalonLogChute</code><br/>
-Class to be used for the Velocity-instantiated log system.
-</p>
-
-<p>
<code>runtime.log.invalid.references = true </code><br/>
Property to turn off the log output when a reference isn't valid.
Good thing to turn off in production, but very valuable
@@ -1965,241 +1926,21 @@ rather than just returning the first non
<section name="Configuring Logging" href="Configuring_Logging">
<p>
-Velocity has a few nice logging features to allow both simplicity and
-flexibility. Without any extra configuration, Velocity will setup a
-file-based logger that will output all logging messages to a file
-called <code>velocity.log</code> in the 'current directory' where
-Velocity was initialized. For more advanced users, you may integrate
-your current logging facilities with Velocity to have all log messages
-sent to your logger.
-</p>
-
-<p>
-Starting with version 1.3, Velocity will automatically use either the
-<a href="http://jakarta.apache.org/avalon/logkit/index.html">
-Jakarta Avalon Logkit</a> logger, or the
-<a href="http://jakarta.apache.org/log4j/">Jakarta Log4j</a> logger.
-It will do so by using whatever it finds in the current classpath, starting
-first with Logkit. If Logkit isn't found, it tries Log4j.
+Since version 2.0, Velocity has switched to the <a
href="http://www.slf4j.org/">SLF4J</a> logging facade.
</p>
<p>
-To utilize this feature, simply use the 'non-dependency' Velocity jar
-(because Logkit is baked into the jar with dependencies) and place
-either the logkit or log4j jar in your classpath.
-</p>
-
-<p>
-In general, you have the following logging options:
+All you have to do to enable logging is to make sure that your classpath
contains the slf4j-api jar, and one and only one slf4j binding jar towards your
favourite logsystem or facade.
</p>
+<p>By default, Velocity will use a logger tagged for the
org.apache.velocity.app.Velocity class.
+You can customize this logger in two ways:
<ul>
-
-<li>
-<b>Default Configuration</b><br/>
-By default, Velocity will create a file-based logger in the current
-directory. See the note above regarding automatic detection of
-Logkit or Log4j to use as the default logging system.
-</li>
-
-<li>
-<b>Existing Log4j Logger</b><br/>
-Starting with version 1.3, Velocity will log its output to an existing
-Log4j Logger setup elsewhere in the application. To use this feature you must
- <ol>
- <li>
- Make sure that the Log4j jar is in your classpath. (You would do this
- anyway since you are using Log4j in the application using Velocity.)
- </li>
- <li>Configure Velocity to use the <code>Log4JLogChute</code> class by
- specifying the name of the existing Logger to use via the
- 'runtime.log.logsystem.log4j.logger' property.
- </li>
- </ol>
-
-Note that this support for Logger is in version 1.5 of Velocity. Further,
-in version 1.5 we removed the now-ancient and very deprecated original
-Log4JLogSystem class and replaced with the current Log4JLogChute class which
-uses the Logger class. We apologize for the confusion, but we needed to move
-on.
-</li>
-
-<li>
-<b>Custom Standalone Logger</b><br/>
-You can create a custom logging class - you just need to implement the
-interface <code>org.apache.velocity.runtime.log.LogChute</code> and
-then simply set the configuration property
-<code>runtime.log.logsystem.class</code> with the
-classname, and Velocity will create an instance of that class at init time.
-You may specify the classname as you specify any other properties. See
-the information on the
-<a href="#thevelocityhelperclass">
-Velocity helper class</a> as well as the
-<a href="#Velocity_Configuration_Keys_and_Values">
-configuration keys and values.</a>
-Please note that the old <code>org.apache.velocity.runtime.log.LogSystem</code>
-interface has been deprecated for v1.5 in favor of the new LogChute interface.
-This is due to significant upgrades to our logging code that could not be
-supported by the LogSystem interface. But don't worry, if you specify a
-custom class that implements the LogSystem interface, it will still work.
-However, it will generate deprecation warnings. You should upgrade your
-custom logger to implement LogChute as soon as possible.
-</li>
-
-<li>
-<b>Integrated Logging</b><br/>
-You can integrate Velocity's logging capabilities with your applications
-existing logging system, simply by implementing the
-<code>org.apache.velocity.runtime.log.LogChute</code> interface. Then,
-pass an instance of your logging class to Velocity via the
-<code>runtime.log.logsystem</code> configuration key before
-initializing the Velocity engine,
-and Velocity will log messages to your application's logger.
-See the information on the
-<a href="#thevelocityhelperclass">Velocity helper class</a>
-as well as the
-<a href="#Velocity_Configuration_Keys_and_Values">configuration keys and
values.</a>
-</li>
-
+<li>By programmatically giving Velocity a living instance of an
orf.slf4j.Logger object, using the runtime.log.instance property key.</li>
+<li>By configuring the name of the logger to be used by your velocity
instance, using the runtime.log.name property key. It can be done from the
velocity.properties file, if present.</li>
</ul>
-
-<a name="usinglog4jwithexistinglogger"><strong>Using Log4j With Existing
Logger</strong></a>
-
-<p>
-Here is an example of how to configure Velocity to log to an existing Log4j
-Logger.
</p>
-<source><![CDATA[
-import org.apache.velocity.app.VelocityEngine;
-import org.apache.velocity.runtime.RuntimeConstants;
-
-import org.apache.log4j.Logger;
-import org.apache.log4j.BasicConfigurator;
-
-public class Log4jLoggerExample
-{
- public static String LOGGER_NAME = "velexample";
-
- public static void main( String args[] )
- throws Exception
- {
- /*
- * configure log4j to log to console
- */
-
- BasicConfigurator.configure();
-
- Logger log = Logger.getLogger( LOGGER_NAME );
-
- log.info("Log4jLoggerExample: ready to start velocity");
-
- /*
- * now create a new VelocityEngine instance, and
- * configure it to use the category
- */
-
- VelocityEngine ve = new VelocityEngine();
-
- ve.setProperty( RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS,
- "org.apache.velocity.runtime.log.Log4JLogChute" );
-
- ve.setProperty("runtime.log.logsystem.log4j.logger",
- LOGGER_NAME);
-
- ve.init();
-
- log.info("follows initialization output from velocity");
- }
-}
-]]></source>
-
-<p>
-Note that the above example can be found in
<code>examples/logger_example</code>.
-</p>
-
-<a name="simpleexampleofacustomlogger"><strong>Simple Example of a Custom
Logger</strong></a>
-
-<p>
-Here is an example of how to use an instantiation of your class that implements
-Velocity's logging system as the logger. Note that we are not passing the name
-of the class to use, but rather a living, existing instantiation of the class
-to be used. All that is required is that it support the
-<code>LogChute</code> interface.
-
-</p>
-
-<source><![CDATA[
-import org.apache.velocity.runtime.log.LogChute;
-import org.apache.velocity.runtime.RuntimeServices;
-...
-
-public class MyClass implements LogChute
-{
-
-...
-
- public MyClass()
- {
- ...
-
- try
- {
- /*
- * register this class as a logger with the Velocity singleton
- * (NOTE: this would not work for the non-singleton method.)
- */
- Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM, this );
- Velocity.init();
- }
- catch (Exception e)
- {
- /*
- * do something
- */
- }
- }
-
- /**
- * This init() will be invoked once by the LogManager
- * to give you the current RuntimeServices intance
- */
- public void init(RuntimeServices rsvc)
- {
- // do nothing
- }
-
- /**
- * This is the method that you implement for Velocity to
- * call with log messages.
- */
- public void log(int level, String message)
- {
- /* do something useful */
- }
-
- /**
- * This is the method that you implement for Velocity to
- * call with log messages.
- */
- public void log(int level, String message, Throwable t)
- {
- /* do something useful */
- }
-
- /**
- * This is the method that you implement for Velocity to
- * check whether a specified log level is enabled.
- */
- public boolean isLevelEnabled(int level)
- {
- /* do something useful */
- return someBooleanValue;
- }
-...
-}
-]]></source>
-
</section>
<section name="Configuring Resource Loaders"
href="Configuring_Resource_Loaders">
Modified: velocity/engine/trunk/src/site/xdoc/stylesheets/project.xml
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/src/site/xdoc/stylesheets/project.xml?rev=1700350&r1=1700349&r2=1700350&view=diff
==============================================================================
--- velocity/engine/trunk/src/site/xdoc/stylesheets/project.xml (original)
+++ velocity/engine/trunk/src/site/xdoc/stylesheets/project.xml Mon Aug 31
21:06:34 2015
@@ -47,7 +47,6 @@
<item name="Javadoc" href="/api/index.html"/>
<item name="Changes"
href="http://velocity.apache.org/engine/devel/changes-report.html"/>
<item name="Resolved Issues"
href="http://velocity.apache.org/engine/devel/jira-report.html"/>
- <item name="Dependencies" href="/jar-dependencies.html"/>
<item name="Source Code Repository"
href="http://svn.apache.org/viewvc/velocity/engine/trunk/"/>
<item name="Building from Source" href="/build.html"/>
</menu>
Modified: velocity/engine/trunk/src/site/xdoc/user-guide.xml
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/src/site/xdoc/user-guide.xml?rev=1700350&r1=1700349&r2=1700350&view=diff
==============================================================================
--- velocity/engine/trunk/src/site/xdoc/user-guide.xml (original)
+++ velocity/engine/trunk/src/site/xdoc/user-guide.xml Mon Aug 31 21:06:34 2015
@@ -250,34 +250,6 @@ Hello $customer.Name!
<version>x.x.x</version>
</dependency>]]>
</source>
- <p>If you want to connect Velocity log facility to Commons Logging, SLF4J,
Log4j or the servlet logger,
- choose the appropriate dependency:</p>
- <source><![CDATA[
-<dependency>
- <groupId>org.apache.velocity</groupId>
- <artifactId>velocity-engine-commons-logging</artifactId>
- <version>x.x.x</version>
-</dependency>
-
-<dependency>
- <groupId>org.apache.velocity</groupId>
- <artifactId>velocity-engine-slf4j</artifactId>
- <version>x.x.x</version>
-</dependency>
-
-<dependency>
- <groupId>org.apache.velocity</groupId>
- <artifactId>velocity-engine-log4j</artifactId>
- <version>x.x.x</version>
-</dependency>
-
-<dependency>
- <groupId>org.apache.velocity</groupId>
- <artifactId>velocity-engine-servlet</artifactId>
- <version>x.x.x</version>
-</dependency>
-]]>
- </source>
</subsection>
<subsection name="Other users" href="Other_users">
<p>
@@ -294,20 +266,7 @@ Hello $customer.Name!
<ul>
<li><strong>velocity-engine-core-x.x.x.jar</strong>: The main
Velocity library. It
must be included at all times.</li>
- <li><strong>velocity-engine-commons-logging-x.x.x.jar</strong>:
It contains the binding to
- Commons Logging, so all log messages will be directed to it. To
be used in
- conjunction with Commons Logging (included in "lib"
directory).</li>
- <li><strong>velocity-engine-slf4j-x.x.x.jar</strong>: It contains the
binding to
- SLF4J, so all log messages will be directed to it. To be used in
- conjunction with SLF4J (included in "lib" directory).</li>
- <li><strong>velocity-engine-log4j-x.x.x.jar</strong>: It
contains the binding to
- Log4j, so all log messages will be directed to it. To be used in
- conjunction with Log4j (included in "lib" directory).</li>
- <li><strong>velocity-engine-servlet-x.x.x.jar</strong>: It
contains the binding to
- the servlet logger. To be used in a servlet container.</li>
</ul>
- <p>The extra jars you will always need always are Commons Collections
and Commons Lang,
- included in "lib" directory.</p>
</subsection>
</section>
Modified: velocity/engine/trunk/src/site/xdoc/webapps.xml
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/src/site/xdoc/webapps.xml?rev=1700350&r1=1700349&r2=1700350&view=diff
==============================================================================
--- velocity/engine/trunk/src/site/xdoc/webapps.xml (original)
+++ velocity/engine/trunk/src/site/xdoc/webapps.xml Mon Aug 31 21:06:34 2015
@@ -254,20 +254,6 @@ by specifying the <code>SecureUberspecto
</subsection>
-<subsection name="Log Files" href="LogFiles">
-
-<p>
-A minor point is that (in some circumstances) Velocity, in the absence of any
log-related configuration, creates a log file in the current directory.
-When Velocity is used in a web application the "current directory" is usually
the current directory from which the application
-server is started. If you start seeing the file "velocity.log" files in
random places on your server filesystem, check
-the Velocity log configuration. This is due to the default use of the Avalon
Log Kit when present in the classpath.
-Typically this occurs when Velocity is used within a web application outside
of web page generation (e.g. for sending email).
-To solve this problem, remove any file labeled "avalon-logkit" from the
classpath or properly configure the log file location.
-</p>
-
-</subsection>
-
-
</section>
<section name="Tutorial" href="Tutorial">
Modified: velocity/engine/trunk/velocity-engine-assembly/pom.xml
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-assembly/pom.xml?rev=1700350&r1=1700349&r2=1700350&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-assembly/pom.xml (original)
+++ velocity/engine/trunk/velocity-engine-assembly/pom.xml Mon Aug 31 21:06:34
2015
@@ -63,31 +63,6 @@
</dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
- <artifactId>velocity-engine-log4j</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.velocity</groupId>
- <artifactId>velocity-engine-commons-logging</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.velocity</groupId>
- <artifactId>velocity-engine-slf4j</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.velocity</groupId>
- <artifactId>velocity-engine-servlet</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.velocity</groupId>
- <artifactId>velocity-engine-uberjar</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.velocity</groupId>
<artifactId>velocity-engine-examples</artifactId>
<version>${project.version}</version>
</dependency>
@@ -179,4 +154,4 @@
</build>
</profile>
</profiles>
-</project>
\ No newline at end of file
+</project>
Modified:
velocity/engine/trunk/velocity-engine-assembly/src/main/assembly/all.xml
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-assembly/src/main/assembly/all.xml?rev=1700350&r1=1700349&r2=1700350&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-assembly/src/main/assembly/all.xml
(original)
+++ velocity/engine/trunk/velocity-engine-assembly/src/main/assembly/all.xml
Mon Aug 31 21:06:34 2015
@@ -39,18 +39,10 @@
<include>org.apache.velocity:velocity-engine*</include>
</includes>
<excludes>
- <exclude>org.apache.velocity:velocity-engine-uberjar</exclude>
<exclude>org.apache.velocity:velocity-engine-examples</exclude>
</excludes>
</dependencySet>
<dependencySet>
- <outputDirectory>/</outputDirectory>
-
<outputFileNameMapping>velocity-${artifact.version}.${artifact.extension}</outputFileNameMapping>
- <includes>
- <include>org.apache.velocity:velocity-engine-uberjar</include>
- </includes>
- </dependencySet>
- <dependencySet>
<outputDirectory>/examples</outputDirectory>
<includes>
<include>org.apache.velocity:velocity-engine-examples</include>
@@ -73,7 +65,6 @@
<include>NOTICE</include>
<include>README.txt</include>
<include>CONTRIBUTORS</include>
- <include>WHY_*_JARS.txt</include>
</includes>
</fileSet>
<fileSet>
@@ -93,38 +84,6 @@
</includes>
</fileSet>
<fileSet>
- <directory>../velocity-engine-commons-logging</directory>
-
<outputDirectory>src/velocity-engine-commons-logging</outputDirectory>
- <includes>
- <include>pom.xml</include>
- <include>src/</include>
- </includes>
- </fileSet>
- <fileSet>
- <directory>../velocity-engine-slf4j</directory>
- <outputDirectory>src/velocity-engine-sl4j</outputDirectory>
- <includes>
- <include>pom.xml</include>
- <include>src/</include>
- </includes>
- </fileSet>
- <fileSet>
- <directory>../velocity-engine-log4j</directory>
- <outputDirectory>src/velocity-engine-log4j</outputDirectory>
- <includes>
- <include>pom.xml</include>
- <include>src/</include>
- </includes>
- </fileSet>
- <fileSet>
- <directory>../velocity-engine-servlet</directory>
- <outputDirectory>src/velocity-engine-servlet</outputDirectory>
- <includes>
- <include>pom.xml</include>
- <include>src/</include>
- </includes>
- </fileSet>
- <fileSet>
<directory>../velocity-engine-examples</directory>
<outputDirectory>src/velocity-engine-examples
</outputDirectory>
@@ -134,14 +93,6 @@
</includes>
</fileSet>
<fileSet>
- <directory>../velocity-engine-uberjar</directory>
- <outputDirectory>src/velocity-engine-uberjar</outputDirectory>
- <includes>
- <include>pom.xml</include>
- <include>src/</include>
- </includes>
- </fileSet>
- <fileSet>
<directory>../velocity-engine-assembly</directory>
<outputDirectory>src/velocity-engine-assembly
</outputDirectory>
@@ -159,26 +110,6 @@
<outputDirectory>docs/velocity-engine-core</outputDirectory>
</fileSet>
<fileSet>
-
<directory>../velocity-engine-commons-logging/target/site</directory>
-
<outputDirectory>docs/velocity-engine-commons-logging</outputDirectory>
- </fileSet>
- <fileSet>
- <directory>../velocity-engine-slf4j/target/site</directory>
- <outputDirectory>docs/velocity-engine-slf4j</outputDirectory>
- </fileSet>
- <fileSet>
- <directory>../velocity-engine-log4j/target/site</directory>
- <outputDirectory>docs/velocity-engine-log4j</outputDirectory>
- </fileSet>
- <fileSet>
- <directory>../velocity-engine-servlet/target/site</directory>
- <outputDirectory>docs/velocity-engine-servlet</outputDirectory>
- </fileSet>
- <fileSet>
- <directory>../velocity-engine-uberjar/target/site</directory>
- <outputDirectory>docs/velocity-engine-uberjar</outputDirectory>
- </fileSet>
- <fileSet>
<directory>../velocity-engine-examples/target/site</directory>
<outputDirectory>docs/velocity-engine-examples</outputDirectory>
</fileSet>
@@ -264,4 +195,4 @@
</includes>
</fileSet>
</fileSets>
-</assembly>
\ No newline at end of file
+</assembly>
Modified: velocity/engine/trunk/velocity-engine-core/pom.xml
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/pom.xml?rev=1700350&r1=1700349&r2=1700350&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/pom.xml (original)
+++ velocity/engine/trunk/velocity-engine-core/pom.xml Mon Aug 31 21:06:34 2015
@@ -210,6 +210,11 @@ Velocity AST Node classes created to src
<version>3.4</version>
</dependency>
<dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.7.12</version>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
@@ -227,6 +232,11 @@ Velocity AST Node classes created to src
<version>2.4</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <version>1.7.12</version>
+ </dependency>
</dependencies>
<reporting>
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/Velocity.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/Velocity.java?rev=1700350&r1=1700349&r2=1700350&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/Velocity.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/Velocity.java
Mon Aug 31 21:06:34 2015
@@ -23,6 +23,8 @@ import java.io.Reader;
import java.io.Writer;
import java.util.Properties;
+import org.slf4j.Logger;
+
import org.apache.commons.collections.ExtendedProperties;
import org.apache.velocity.Template;
import org.apache.velocity.context.Context;
@@ -31,7 +33,6 @@ import org.apache.velocity.exception.Par
import org.apache.velocity.exception.ResourceNotFoundException;
import org.apache.velocity.runtime.RuntimeConstants;
import org.apache.velocity.runtime.RuntimeSingleton;
-import org.apache.velocity.runtime.log.Log;
/**
* This class provides services to the application
@@ -337,7 +338,7 @@ public class Velocity implements Runtime
* @return A convenience Log instance that wraps the current LogChute.
* @since 1.5
*/
- public static Log getLog()
+ public static Logger getLog()
{
return RuntimeSingleton.getLog();
}
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/VelocityEngine.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/VelocityEngine.java?rev=1700350&r1=1700349&r2=1700350&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/VelocityEngine.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/app/VelocityEngine.java
Mon Aug 31 21:06:34 2015
@@ -23,6 +23,8 @@ import java.io.Reader;
import java.io.Writer;
import java.util.Properties;
+import org.slf4j.Logger;
+
import org.apache.commons.collections.ExtendedProperties;
import org.apache.velocity.Template;
import org.apache.velocity.context.Context;
@@ -31,7 +33,6 @@ import org.apache.velocity.exception.Par
import org.apache.velocity.exception.ResourceNotFoundException;
import org.apache.velocity.runtime.RuntimeConstants;
import org.apache.velocity.runtime.RuntimeInstance;
-import org.apache.velocity.runtime.log.Log;
/**
* <p>
@@ -351,7 +352,7 @@ public class VelocityEngine implements R
* @return A log object.
* @since 1.5
*/
- public Log getLog()
+ public Logger getLog()
{
return ri.getLog();
}
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/exception/MethodInvocationException.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/exception/MethodInvocationException.java?rev=1700350&r1=1700349&r2=1700350&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/exception/MethodInvocationException.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/exception/MethodInvocationException.java
Mon Aug 31 21:06:34 2015
@@ -1,6 +1,6 @@
package org.apache.velocity.exception;
-import org.apache.velocity.runtime.log.Log;
+import org.apache.velocity.util.StringUtils;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -134,7 +134,7 @@ public class MethodInvocationException e
StringBuffer message = new StringBuffer();
message.append(super.getMessage());
message.append(" at ");
- message.append(Log.formatFileString(templateName, lineNumber,
columnNumber));
+ message.append(StringUtils.formatFileString(templateName, lineNumber,
columnNumber));
return message.toString();
}
}
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/exception/ParseErrorException.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/exception/ParseErrorException.java?rev=1700350&r1=1700349&r2=1700350&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/exception/ParseErrorException.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/exception/ParseErrorException.java
Mon Aug 31 21:06:34 2015
@@ -22,9 +22,9 @@ package org.apache.velocity.exception;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.apache.velocity.runtime.log.Log;
import org.apache.velocity.runtime.parser.ParseException;
import org.apache.velocity.util.introspection.Info;
+import org.apache.velocity.util.StringUtils;
/**
* Application-level exception thrown when a resource of any type
@@ -116,7 +116,7 @@ public class ParseErrorException extends
columnNumber = Integer.parseInt(match.group(2));
String restOfMsg = match.group(3);
msg = "Lexical error, " + restOfMsg + " at "
- + Log.formatFileString(templateName, lineNumber,
columnNumber);
+ + StringUtils.formatFileString(templateName, lineNumber,
columnNumber);
}
// ugly, ugly, ugly...
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=1700350&r1=1700349&r2=1700350&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
Mon Aug 31 21:06:34 2015
@@ -44,14 +44,11 @@ public interface RuntimeConstants
* ----------------------------------------------------------------------
*/
- /** Location of the velocity log file. */
- String RUNTIME_LOG = "runtime.log";
-
/** externally provided logger. */
- String RUNTIME_LOG_LOGSYSTEM = "runtime.log.logsystem";
+ String RUNTIME_LOG_INSTANCE = "runtime.log.instance";
- /** class of log system to use. */
- String RUNTIME_LOG_LOGSYSTEM_CLASS = "runtime.log.logsystem.class";
+ /** externally provided logger name. */
+ String RUNTIME_LOG_NAME = "runtime.log.name";
/**
* Properties referenced in the template are required to exist the object
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=1700350&r1=1700349&r2=1700350&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
Mon Aug 31 21:06:34 2015
@@ -32,8 +32,12 @@ import java.util.List;
import java.util.Map;
import java.util.Properties;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import org.apache.commons.collections.ExtendedProperties;
import org.apache.velocity.Template;
+import org.apache.velocity.app.Velocity;
import org.apache.velocity.app.event.EventCartridge;
import org.apache.velocity.app.event.EventHandler;
import org.apache.velocity.app.event.IncludeEventHandler;
@@ -52,8 +56,6 @@ import org.apache.velocity.runtime.direc
import org.apache.velocity.runtime.directive.VelocimacroProxy;
import org.apache.velocity.runtime.directive.Scope;
import org.apache.velocity.runtime.directive.StopCommand;
-import org.apache.velocity.runtime.log.Log;
-import org.apache.velocity.runtime.log.LogManager;
import org.apache.velocity.runtime.parser.ParseException;
import org.apache.velocity.runtime.parser.Parser;
import org.apache.velocity.runtime.parser.node.Node;
@@ -77,23 +79,9 @@ import org.apache.velocity.util.introspe
* in order to get Velocity to perform.
*
* The Runtime will also cooperate with external
- * systems like Turbine. Runtime properties can
- * set and then the Runtime is initialized.
- *
- * Turbine, for example, knows where the templates
- * are to be loaded from, and where the Velocity
- * log file should be placed.
- *
- * So in the case of Velocity cooperating with Turbine
- * the code might look something like the following:
+ * systems, which can make all needed setProperty() calls
+ * before calling init().
*
- * <blockquote><code><pre>
- * ri.setProperty(Runtime.FILE_RESOURCE_LOADER_PATH, templatePath);
- * ri.setProperty(Runtime.RUNTIME_LOG, pathToVelocityLog);
- * ri.init();
- * </pre></code></blockquote>
- *
- * <pre>
* -----------------------------------------------------------------------
* N O T E S O N R U N T I M E I N I T I A L I Z A T I O N
* -----------------------------------------------------------------------
@@ -124,12 +112,9 @@ public class RuntimeInstance implements
private VelocimacroFactory vmFactory = null;
/**
- * The Runtime logger. We start with an instance of
- * a 'primordial logger', which just collects log messages
- * then, when the log system is initialized, all the
- * messages get dumped out of the primordial one into the real one.
+ * The Runtime logger. The default instance is the "Velocity" logger.
*/
- private Log log = new Log();
+ private Logger log = LoggerFactory.getLogger(Velocity.class);
/**
* The Runtime parser pool
@@ -281,7 +266,6 @@ public class RuntimeInstance implements
this.eventCartridge = null;
this.initialized = false;
this.initializing = false;
- this.log = new Log();
this.overridingProperties = null;
this.parserPool = null;
this.provideEvaluateScope = false;
@@ -879,11 +863,49 @@ public class RuntimeInstance implements
*/
private void initializeLog()
{
- // since the Log we started with was just placeholding,
- // let's update it with the real LogChute settings.
+ // if we were provided a specific logger or logger name, let's use it
try
{
- LogManager.updateLog(this.log, this);
+ /* If a Logger instance was set as a configuration
+ * value, use that. This is any class the user specifies.
+ */
+ Object o = getProperty(RuntimeConstants.RUNTIME_LOG_INSTANCE);
+ if (o != null)
+ {
+ // check for a Logger
+ if (Logger.class.isAssignableFrom(o.getClass()))
+ {
+ //looks ok
+ log = (Logger)o;
+ }
+ else
+ {
+ String msg = o.getClass().getName() + " object set as
runtime.log.instance is not a valid org.slf4j.Logger implementation.";
+ log.error(msg);
+ throw new VelocityException(msg);
+ }
+ }
+ else
+ {
+ /* otherwise, see if a logger name was specified.
+ */
+ o = getProperty(RuntimeConstants.RUNTIME_LOG_NAME);
+ if (o != null)
+ {
+ if (o instanceof String)
+ {
+ log = LoggerFactory.getLogger((String)o);
+ }
+ else
+ {
+ String msg = o.getClass().getName() + " object set as
runtime.log.name is not a valid string.";
+ log.error(msg);
+ throw new VelocityException(msg);
+ }
+ }
+ }
+ /* else keep our default Velocity logger
+ */
}
catch (Exception e)
{
@@ -1617,7 +1639,7 @@ public class RuntimeInstance implements
* @return A convenience Log instance that wraps the current LogChute.
* @since 1.5
*/
- public Log getLog()
+ public Logger getLog()
{
return log;
}
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=1700350&r1=1700349&r2=1700350&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
Mon Aug 31 21:06:34 2015
@@ -25,6 +25,8 @@ import java.io.Writer;
import java.util.List;
import java.util.Properties;
+import org.slf4j.Logger;
+
import org.apache.commons.collections.ExtendedProperties;
import org.apache.velocity.Template;
import org.apache.velocity.app.event.EventCartridge;
@@ -34,7 +36,6 @@ import org.apache.velocity.exception.Par
import org.apache.velocity.exception.ResourceNotFoundException;
import org.apache.velocity.runtime.directive.Directive;
import org.apache.velocity.runtime.directive.Macro;
-import org.apache.velocity.runtime.log.Log;
import org.apache.velocity.runtime.parser.ParseException;
import org.apache.velocity.runtime.parser.Parser;
import org.apache.velocity.runtime.parser.node.Node;
@@ -464,7 +465,7 @@ public interface RuntimeServices
* Returns a convenient Log instance that wraps the current LogChute.
* @return A log object.
*/
- public Log getLog();
+ public Logger getLog();
/**
* Returns the event handlers for the application.
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeSingleton.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeSingleton.java?rev=1700350&r1=1700349&r2=1700350&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeSingleton.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeSingleton.java
Mon Aug 31 21:06:34 2015
@@ -23,6 +23,8 @@ import java.io.Reader;
import java.util.List;
import java.util.Properties;
+import org.slf4j.Logger;
+
import org.apache.commons.collections.ExtendedProperties;
import org.apache.velocity.Template;
import org.apache.velocity.app.event.EventCartridge;
@@ -30,7 +32,6 @@ import org.apache.velocity.exception.Par
import org.apache.velocity.exception.ResourceNotFoundException;
import org.apache.velocity.runtime.directive.Directive;
import org.apache.velocity.runtime.directive.Macro;
-import org.apache.velocity.runtime.log.Log;
import org.apache.velocity.runtime.parser.ParseException;
import org.apache.velocity.runtime.parser.node.Node;
import org.apache.velocity.runtime.parser.node.SimpleNode;
@@ -46,23 +47,9 @@ import org.apache.velocity.util.introspe
* in order to get Velocity to perform.
*
* The Runtime will also cooperate with external
- * systems like Turbine. Runtime properties can
- * set and then the Runtime is initialized.
- *
- * Turbine for example knows where the templates
- * are to be loaded from, and where the velocity
- * log file should be placed.
- *
- * So in the case of Velocity cooperating with Turbine
- * the code might look something like the following:
- *
- * <pre>
- * RuntimeSingleton.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH,
templatePath);
- * RuntimeSingleton.setProperty(RuntimeConstants.RUNTIME_LOG,
pathToVelocityLog);
- * RuntimeSingleton.init();
- * </pre>
+ * systems, which can make all needed setProperty() calls
+ * before calling init().
*
- * <pre>
* -----------------------------------------------------------------------
* N O T E S O N R U N T I M E I N I T I A L I Z A T I O N
* -----------------------------------------------------------------------
@@ -389,7 +376,7 @@ public class RuntimeSingleton implements
* @see RuntimeInstance#getLog()
* @since 1.5
*/
- public static Log getLog()
+ public static Logger getLog()
{
return ri.getLog();
}
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=1700350&r1=1700349&r2=1700350&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
Mon Aug 31 21:06:34 2015
@@ -26,13 +26,14 @@ import java.util.List;
import java.util.Map;
import java.util.Vector;
+import org.slf4j.Logger;
+
import org.apache.commons.lang3.StringUtils;
import org.apache.velocity.Template;
import org.apache.velocity.exception.VelocityException;
import org.apache.velocity.runtime.directive.Directive;
import org.apache.velocity.runtime.directive.Macro;
import org.apache.velocity.runtime.directive.VelocimacroProxy;
-import org.apache.velocity.runtime.log.LogDisplayWrapper;
import org.apache.velocity.runtime.parser.ParseException;
import org.apache.velocity.runtime.parser.node.Node;
@@ -54,7 +55,7 @@ public class VelocimacroFactory
/**
* the log for this instance
*/
- private final LogDisplayWrapper log;
+ private final Logger log;
/**
* VMManager : deal with namespace management
@@ -106,8 +107,7 @@ public class VelocimacroFactory
public VelocimacroFactory(final RuntimeServices rsvc)
{
this.rsvc = rsvc;
- this.log = new LogDisplayWrapper(rsvc.getLog(), "Velocimacro : ",
- rsvc.getBoolean(RuntimeConstants.VM_MESSAGES_ON, true));
+ this.log = rsvc.getLog();
/*
* we always access in a synchronized(), so we
@@ -215,7 +215,7 @@ public class VelocimacroFactory
catch (Exception e)
{
String msg = "Velocimacro : Error using VM
library : " + lib;
- log.error(true, msg, e);
+ log.error(msg, e);
throw new VelocityException(msg, e);
}
@@ -649,7 +649,7 @@ public class VelocimacroFactory
catch (Exception e)
{
String msg = "Velocimacro : Error using VM library : "
+ lib;
- log.error(true, 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/Block.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Block.java?rev=1700350&r1=1700349&r2=1700350&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Block.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Block.java
Mon Aug 31 21:06:34 2015
@@ -23,12 +23,14 @@ import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
+import org.slf4j.Logger;
+
import org.apache.velocity.context.InternalContextAdapter;
import org.apache.velocity.exception.TemplateInitException;
import org.apache.velocity.runtime.Renderable;
import org.apache.velocity.runtime.RuntimeServices;
-import org.apache.velocity.runtime.log.Log;
import org.apache.velocity.runtime.parser.node.Node;
+import org.apache.velocity.util.StringUtils;
/**
* Directive that puts an unrendered AST block in the context
@@ -44,7 +46,7 @@ import org.apache.velocity.runtime.parse
public abstract class Block extends Directive
{
protected Node block;
- protected Log log;
+ protected Logger log;
protected int maxDepth;
protected String key;
@@ -83,7 +85,7 @@ public abstract class Block extends Dire
catch (IOException e)
{
String msg = "Failed to render " + id(context) + " to writer "
- + " at " + Log.formatFileString(this);
+ + " at " + StringUtils.formatFileString(this);
log.error(msg, e);
throw new RuntimeException(msg, e);
@@ -151,7 +153,7 @@ public abstract class Block extends Dire
* pulling it off properly.
*/
parent.log.debug("Max recursion depth reached for " +
parent.id(context)
- + " at " + Log.formatFileString(parent));
+ + " at " + StringUtils.formatFileString(parent));
depth--;
return false;
}
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Break.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Break.java?rev=1700350&r1=1700349&r2=1700350&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Break.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Break.java
Mon Aug 31 21:06:34 2015
@@ -23,11 +23,11 @@ import java.io.Writer;
import java.util.ArrayList;
import org.apache.velocity.context.InternalContextAdapter;
import org.apache.velocity.exception.VelocityException;
-import org.apache.velocity.runtime.log.Log;
import org.apache.velocity.runtime.RuntimeServices;
import org.apache.velocity.runtime.parser.ParseException;
import org.apache.velocity.runtime.parser.Token;
import org.apache.velocity.runtime.parser.node.Node;
+import org.apache.velocity.util.StringUtils;
/**
* Break directive used for interrupting scopes.
@@ -98,7 +98,7 @@ public class Break extends Directive
{
throw new VelocityException(node.jjtGetChild(0).literal()+
" is not a valid " + Scope.class.getName() + " instance at "
- + Log.formatFileString(this));
+ + StringUtils.formatFileString(this));
}
}
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Define.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Define.java?rev=1700350&r1=1700349&r2=1700350&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Define.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Define.java
Mon Aug 31 21:06:34 2015
@@ -25,13 +25,13 @@ import java.util.ArrayList;
import org.apache.velocity.context.InternalContextAdapter;
import org.apache.velocity.exception.TemplateInitException;
import org.apache.velocity.exception.VelocityException;
-import org.apache.velocity.runtime.log.Log;
import org.apache.velocity.runtime.RuntimeConstants;
import org.apache.velocity.runtime.RuntimeServices;
import org.apache.velocity.runtime.parser.ParseException;
import org.apache.velocity.runtime.parser.ParserTreeConstants;
import org.apache.velocity.runtime.parser.Token;
import org.apache.velocity.runtime.parser.node.Node;
+import org.apache.velocity.util.StringUtils;
/**
* Directive that puts an unrendered AST block in the context
@@ -64,7 +64,7 @@ public class Define extends Block
if ( node.jjtGetNumChildren() != 2 )
{
throw new VelocityException("parameter missing: block name at "
- + Log.formatFileString(this));
+ + StringUtils.formatFileString(this));
}
/*
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=1700350&r1=1700349&r2=1700350&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
Mon Aug 31 21:06:34 2015
@@ -29,13 +29,13 @@ import org.apache.velocity.exception.Tem
import org.apache.velocity.exception.VelocityException;
import org.apache.velocity.runtime.RuntimeConstants;
import org.apache.velocity.runtime.RuntimeServices;
-import org.apache.velocity.runtime.log.Log;
import org.apache.velocity.runtime.parser.ParseException;
import org.apache.velocity.runtime.parser.ParserTreeConstants;
import org.apache.velocity.runtime.parser.Token;
import org.apache.velocity.runtime.parser.node.ASTReference;
import org.apache.velocity.runtime.parser.node.Node;
import org.apache.velocity.runtime.parser.node.SimpleNode;
+import org.apache.velocity.util.StringUtils;
import org.apache.velocity.util.introspection.Info;
/**
@@ -187,7 +187,7 @@ public class Foreach extends Directive
catch (Exception ee)
{
String msg = "Error getting iterator for #foreach parameter "
- + node.literal() + " at " + Log.formatFileString(node);
+ + node.literal() + " at " +
StringUtils.formatFileString(node);
rsvc.getLog().error(msg, ee);
throw new VelocityException(msg, ee);
}
@@ -195,7 +195,7 @@ public class Foreach extends Directive
if (i == null && !skipInvalidIterator)
{
String msg = "#foreach parameter " + node.literal() + " at "
- + Log.formatFileString(node) + " is of type " +
iterable.getClass().getName()
+ + StringUtils.formatFileString(node) + " is of type " +
iterable.getClass().getName()
+ " and cannot be iterated by " +
rsvc.getUberspect().getClass().getName();
rsvc.getLog().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=1700350&r1=1700349&r2=1700350&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
Mon Aug 31 21:06:34 2015
@@ -30,10 +30,10 @@ import org.apache.velocity.exception.Tem
import org.apache.velocity.exception.VelocityException;
import org.apache.velocity.runtime.RuntimeConstants;
import org.apache.velocity.runtime.RuntimeServices;
-import org.apache.velocity.runtime.log.Log;
import org.apache.velocity.runtime.parser.ParserTreeConstants;
import org.apache.velocity.runtime.parser.node.Node;
import org.apache.velocity.runtime.resource.Resource;
+import org.apache.velocity.util.StringUtils;
/**
* <p>Pluggable directive that handles the #include() statement in VTL.
@@ -168,7 +168,7 @@ public class Include extends InputBase
else
{
String msg = "invalid #include() argument '"
- + n.toString() + "' at " + Log.formatFileString(this);
+ + n.toString() + "' at " +
StringUtils.formatFileString(this);
rsvc.getLog().error(msg);
outputErrorToStream( writer, "error with arg " + i
+ " please see log.");
@@ -243,7 +243,7 @@ public class Include extends InputBase
* the arg wasn't found. Note it and throw
*/
rsvc.getLog().error("#include(): cannot find resource '" + arg +
- "', called at " + Log.formatFileString(this));
+ "', called at " +
StringUtils.formatFileString(this));
throw rnfe;
}
@@ -253,13 +253,13 @@ public class Include extends InputBase
catch( RuntimeException e )
{
rsvc.getLog().error("#include(): arg = '" + arg +
- "', called at " + Log.formatFileString(this));
+ "', called at " +
StringUtils.formatFileString(this));
throw e;
}
catch (Exception e)
{
String msg = "#include(): arg = '" + arg +
- "', called at " + Log.formatFileString(this);
+ "', called at " + StringUtils.formatFileString(this);
rsvc.getLog().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=1700350&r1=1700349&r2=1700350&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
Mon Aug 31 21:06:34 2015
@@ -27,7 +27,6 @@ import java.util.List;
import org.apache.velocity.context.InternalContextAdapter;
import org.apache.velocity.exception.TemplateInitException;
import org.apache.velocity.runtime.RuntimeServices;
-import org.apache.velocity.runtime.log.Log;
import org.apache.velocity.runtime.parser.ParseException;
import org.apache.velocity.runtime.parser.ParserTreeConstants;
import org.apache.velocity.runtime.parser.Token;
@@ -232,7 +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);
+ rsvc.getLog().debug(msg.toString());
System.out.println("---- > macro: " + msg);
}
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/MacroParseException.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/MacroParseException.java?rev=1700350&r1=1700349&r2=1700350&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/MacroParseException.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/MacroParseException.java
Mon Aug 31 21:06:34 2015
@@ -20,9 +20,9 @@ package org.apache.velocity.runtime.dire
*/
import org.apache.velocity.exception.ExtendedParseException;
-import org.apache.velocity.runtime.log.Log;
import org.apache.velocity.runtime.parser.ParseException;
import org.apache.velocity.runtime.parser.Token;
+import org.apache.velocity.util.StringUtils;
/**
* Exception to indicate problem happened while constructing #macro()
@@ -196,7 +196,7 @@ public class MacroParseException
*/
protected void appendTemplateInfo(final StringBuffer sb)
{
- sb.append(Log.formatFileString(getTemplateName(), getLineNumber(),
getColumnNumber()));
+ sb.append(StringUtils.formatFileString(getTemplateName(),
getLineNumber(), getColumnNumber()));
sb.append(eol);
}
}
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=1700350&r1=1700349&r2=1700350&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
Mon Aug 31 21:06:34 2015
@@ -34,12 +34,12 @@ import org.apache.velocity.exception.Tem
import org.apache.velocity.exception.VelocityException;
import org.apache.velocity.runtime.RuntimeConstants;
import org.apache.velocity.runtime.RuntimeServices;
-import org.apache.velocity.runtime.log.Log;
import org.apache.velocity.runtime.parser.ParseException;
import org.apache.velocity.runtime.parser.ParserTreeConstants;
import org.apache.velocity.runtime.parser.Token;
import org.apache.velocity.runtime.parser.node.Node;
import org.apache.velocity.runtime.parser.node.SimpleNode;
+import org.apache.velocity.util.StringUtils;
/**
* Pluggable directive that handles the <code>#parse()</code>
@@ -142,7 +142,7 @@ public class Parse extends InputBase
if ( node.jjtGetNumChildren() == 0 )
{
throw new VelocityException("#parse(): argument missing at " +
- Log.formatFileString(this));
+ StringUtils.formatFileString(this));
}
/*
@@ -152,7 +152,7 @@ public class Parse extends InputBase
if (value == null && rsvc.getLog().isDebugEnabled())
{
rsvc.getLog().debug("#parse(): null argument at " +
- Log.formatFileString(this));
+ StringUtils.formatFileString(this));
}
/*
@@ -171,7 +171,7 @@ public class Parse extends InputBase
if (strictRef && value == null && arg == null)
{
throw new VelocityException("The argument to #parse returned null
at "
- + Log.formatFileString(this));
+ + StringUtils.formatFileString(this));
}
/*
@@ -221,7 +221,7 @@ public class Parse extends InputBase
* the arg wasn't found. Note it and throw
*/
rsvc.getLog().error("#parse(): cannot find template '" + arg +
- "', called at " + Log.formatFileString(this));
+ "', called at " +
StringUtils.formatFileString(this));
throw rnfe;
}
catch ( ParseErrorException pee )
@@ -231,7 +231,7 @@ public class Parse extends InputBase
* note it and throw
*/
rsvc.getLog().error("#parse(): syntax error in #parse()-ed
template '"
- + arg + "', called at " +
Log.formatFileString(this));
+ + arg + "', called at " +
StringUtils.formatFileString(this));
throw pee;
}
/**
@@ -240,13 +240,13 @@ public class Parse extends InputBase
catch( RuntimeException e )
{
rsvc.getLog().error("Exception rendering #parse(" + arg + ") at " +
- Log.formatFileString(this));
+ StringUtils.formatFileString(this));
throw e;
}
catch ( Exception e)
{
String msg = "Exception rendering #parse(" + arg + ") at " +
- Log.formatFileString(this);
+ StringUtils.formatFileString(this);
rsvc.getLog().error(msg, e);
throw new VelocityException(msg, e);
}
@@ -294,13 +294,13 @@ 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.formatFileString(this));
+ StringUtils.formatFileString(this));
throw e;
}
catch ( Exception e )
{
String msg = "Exception rendering #parse(" + arg + ") at " +
- Log.formatFileString(this);
+ StringUtils.formatFileString(this);
rsvc.getLog().error(msg, e);
throw new VelocityException(msg, e);
}
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=1700350&r1=1700349&r2=1700350&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
Mon Aug 31 21:06:34 2015
@@ -32,10 +32,10 @@ import org.apache.velocity.exception.Vel
import org.apache.velocity.runtime.Renderable;
import org.apache.velocity.runtime.RuntimeConstants;
import org.apache.velocity.runtime.RuntimeServices;
-import org.apache.velocity.runtime.log.Log;
import org.apache.velocity.runtime.parser.ParserTreeConstants;
import org.apache.velocity.runtime.parser.Token;
import org.apache.velocity.runtime.parser.node.Node;
+import org.apache.velocity.util.StringUtils;
/**
* This class acts as a proxy for potential macros. When the AST is built
@@ -160,7 +160,7 @@ public class RuntimeMacro extends Direct
if (child.getType() == ParserTreeConstants.JJTWORD)
{
badArgsErrorMsg = "Invalid arg '" + child.getFirstToken().image
- + "' in macro #" + macroName + " at " +
Log.formatFileString(child);
+ + "' in macro #" + macroName + " at " +
StringUtils.formatFileString(child);
if (strictRef) // If strict, throw now
{
@@ -315,13 +315,13 @@ public class RuntimeMacro extends Direct
* this is also true for the following catch blocks.
*/
rsvc.getLog().error("Exception in macro #" + macroName + "
called at " +
- Log.formatFileString(node));
+ StringUtils.formatFileString(node));
throw e;
}
catch (IOException e)
{
rsvc.getLog().error("Exception in macro #" + macroName + "
called at " +
- Log.formatFileString(node));
+ StringUtils.formatFileString(node));
throw e;
}
finally
@@ -332,7 +332,7 @@ public class RuntimeMacro extends Direct
else if (strictRef)
{
throw new VelocityException("Macro '#" + macroName + "' is not
defined at "
- + Log.formatFileString(node));
+ + StringUtils.formatFileString(node));
}
/**
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=1700350&r1=1700349&r2=1700350&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
Mon Aug 31 21:06:34 2015
@@ -30,9 +30,9 @@ import org.apache.velocity.runtime.Rende
import org.apache.velocity.runtime.RuntimeConstants;
import org.apache.velocity.runtime.RuntimeServices;
import org.apache.velocity.runtime.directive.Macro.MacroArg;
-import org.apache.velocity.runtime.log.Log;
import org.apache.velocity.runtime.parser.node.Node;
import org.apache.velocity.runtime.parser.node.SimpleNode;
+import org.apache.velocity.util.StringUtils;
/**
* VelocimacroProxy.java
@@ -254,7 +254,7 @@ public class VelocimacroProxy extends Di
{
throw new VelocityException("Provided " + callArgNum + "
arguments but macro #"
+ macroArgs.get(0).name + " accepts at most " +
(macroArgs.size()-1)
- + " at " + Log.formatFileString(node));
+ + " at " + StringUtils.formatFileString(node));
}
else if (rsvc.getLog().isDebugEnabled())
{
@@ -289,7 +289,7 @@ public class VelocimacroProxy extends Di
}
out.append(stack[i]);
}
- out.append(" at " + Log.formatFileString(this));
+ out.append(" at " + StringUtils.formatFileString(this));
rsvc.getLog().error(out.toString());
// clean out the macro stack, since we just broke it
@@ -341,7 +341,7 @@ public class VelocimacroProxy extends Di
}
throw new VelocityException("Need at least " + minArgNum + "
argument for macro #"
+ macroArgs.get(0).name + " but only " + callArgNum + "
where provided at "
- + Log.formatFileString(node));
+ + StringUtils.formatFileString(node));
}
else
{
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/TemplateParseException.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/TemplateParseException.java?rev=1700350&r1=1700349&r2=1700350&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/TemplateParseException.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/TemplateParseException.java
Mon Aug 31 21:06:34 2015
@@ -20,8 +20,8 @@ package org.apache.velocity.runtime.pars
*/
import org.apache.velocity.exception.ExtendedParseException;
-import org.apache.velocity.runtime.log.Log;
+import org.apache.velocity.util.StringUtils;
/**
* This is an extension of the ParseException, which also takes a
@@ -234,7 +234,7 @@ public class TemplateParseException
*/
protected void appendTemplateInfo(final StringBuffer sb)
{
- sb.append(Log.formatFileString(getTemplateName(), getLineNumber(),
getColumnNumber()));
+ sb.append(StringUtils.formatFileString(getTemplateName(),
getLineNumber(), getColumnNumber()));
sb.append(eol);
}
}
Modified:
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTComparisonNode.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTComparisonNode.java?rev=1700350&r1=1700349&r2=1700350&view=diff
==============================================================================
---
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTComparisonNode.java
(original)
+++
velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTComparisonNode.java
Mon Aug 31 21:06:34 2015
@@ -23,9 +23,9 @@ import org.apache.velocity.context.Inter
import org.apache.velocity.exception.MethodInvocationException;
import org.apache.velocity.exception.VelocityException;
import org.apache.velocity.runtime.RuntimeConstants;
-import org.apache.velocity.runtime.log.Log;
import org.apache.velocity.runtime.parser.Parser;
import org.apache.velocity.util.DuckType;
+import org.apache.velocity.util.StringUtils;
/**
* Numeric comparison support<br><br>
@@ -92,7 +92,7 @@ public abstract class ASTComparisonNode
+ " side ("
+ jjtGetChild( (left == null? 0 : 1) ).literal()
+ ") of comparison operation has null value at "
- + Log.formatFileString(this);
+ + StringUtils.formatFileString(this);
if (rsvc.getBoolean(RuntimeConstants.RUNTIME_REFERENCES_STRICT, false))
{
throw new VelocityException(msg);
@@ -129,7 +129,7 @@ public abstract class ASTComparisonNode
// by default, log and bail
String msg = (right instanceof Number ? "Left" : "Right")
+ " side of comparison operation is not a number at "
- + Log.formatFileString(this);
+ + StringUtils.formatFileString(this);
if (rsvc.getBoolean(RuntimeConstants.RUNTIME_REFERENCES_STRICT, false))
{
throw new VelocityException(msg);