Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ParserTestCase.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ParserTestCase.java?rev=1700350&r1=1700349&r2=1700350&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ParserTestCase.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ParserTestCase.java Mon Aug 31 21:06:34 2015 @@ -30,6 +30,8 @@ import junit.framework.TestSuite; import org.apache.velocity.VelocityContext; import org.apache.velocity.app.VelocityEngine; import org.apache.velocity.exception.ParseErrorException; +import org.apache.velocity.runtime.RuntimeConstants; +import org.apache.velocity.test.misc.TestLogger; /** * More specific parser tests where just templating @@ -57,7 +59,8 @@ public class ParserTestCase extends Test throws Exception { VelocityEngine ve = new VelocityEngine(); - + TestLogger logger = new TestLogger(); + ve.setProperty(RuntimeConstants.RUNTIME_LOG_INSTANCE, logger); ve.init(); /* @@ -92,7 +95,8 @@ public class ParserTestCase extends Test throws Exception { VelocityEngine ve = new VelocityEngine(); - + TestLogger logger = new TestLogger(); + ve.setProperty(RuntimeConstants.RUNTIME_LOG_INSTANCE, logger); ve.init(); /* @@ -128,7 +132,8 @@ public class ParserTestCase extends Test throws Exception { VelocityEngine ve = new VelocityEngine(); - + TestLogger logger = new TestLogger(); + ve.setProperty(RuntimeConstants.RUNTIME_LOG_INSTANCE, logger); ve.init(); /* @@ -171,7 +176,8 @@ public class ParserTestCase extends Test throws Exception { VelocityEngine ve = new VelocityEngine(); - + TestLogger logger = new TestLogger(); + ve.setProperty(RuntimeConstants.RUNTIME_LOG_INSTANCE, logger); ve.init(); String template = "$counter";
Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ResourceExistsTestCase.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ResourceExistsTestCase.java?rev=1700350&r1=1700349&r2=1700350&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ResourceExistsTestCase.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ResourceExistsTestCase.java Mon Aug 31 21:06:34 2015 @@ -22,7 +22,7 @@ package org.apache.velocity.test; import org.apache.velocity.app.VelocityEngine; import org.apache.velocity.runtime.RuntimeConstants; import org.apache.velocity.runtime.resource.loader.StringResourceLoader; -import org.apache.velocity.test.misc.TestLogChute; +import org.apache.velocity.test.misc.TestLogger; /** * Test the resource exists method @@ -33,7 +33,7 @@ public class ResourceExistsTestCase exte { private VelocityEngine velocity; private String path = TEST_COMPARE_DIR + "/resourceexists"; - private TestLogChute logger = new TestLogChute(); + private TestLogger logger = new TestLogger(); public ResourceExistsTestCase(String name) { @@ -50,7 +50,7 @@ try { // actual instance of logger logger.on(); - velocity.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM, logger); + velocity.setProperty(RuntimeConstants.RUNTIME_LOG_INSTANCE, logger); velocity.setProperty("runtime.log.logsystem.test.level", "debug"); } catch (Exception e) { System.out.println("exception via gump: "+e); Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ResourceLoaderInstanceTestCase.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ResourceLoaderInstanceTestCase.java?rev=1700350&r1=1700349&r2=1700350&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ResourceLoaderInstanceTestCase.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/ResourceLoaderInstanceTestCase.java Mon Aug 31 21:06:34 2015 @@ -32,7 +32,7 @@ import org.apache.velocity.VelocityConte import org.apache.velocity.app.Velocity; import org.apache.velocity.runtime.RuntimeConstants; import org.apache.velocity.runtime.RuntimeSingleton; -import org.apache.velocity.test.misc.TestLogChute; +import org.apache.velocity.test.misc.TestLogger; import org.apache.velocity.runtime.resource.loader.FileResourceLoader; import org.apache.velocity.runtime.resource.loader.ResourceLoader; @@ -75,7 +75,7 @@ public class ResourceLoaderInstanceTestC */ private static final String COMPARE_DIR = TEST_COMPARE_DIR + "/resourceinstance/compare"; - private TestLogChute logger = new TestLogChute(); + private TestLogger logger = new TestLogger(); /** * Default constructor. @@ -99,7 +99,7 @@ public class ResourceLoaderInstanceTestC // actual instance of logger logger.on(); - Velocity.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM, logger); + Velocity.setProperty(RuntimeConstants.RUNTIME_LOG_INSTANCE, logger); Velocity.setProperty("runtime.log.logsystem.test.level", "debug"); Velocity.init(); Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/StopDirectiveTestCase.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/StopDirectiveTestCase.java?rev=1700350&r1=1700349&r2=1700350&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/StopDirectiveTestCase.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/StopDirectiveTestCase.java Mon Aug 31 21:06:34 2015 @@ -21,7 +21,7 @@ package org.apache.velocity.test; import org.apache.velocity.test.BaseTestCase; import org.apache.velocity.test.TemplateTestBase; -import org.apache.velocity.test.misc.TestLogChute; +import org.apache.velocity.test.misc.TestLogger; import org.apache.velocity.runtime.RuntimeConstants; /** @@ -72,8 +72,7 @@ public class StopDirectiveTestCase exten public void testStopMessage() { - log.setEnabledLevel(TestLogChute.DEBUG_ID); - log.off(); + log.setEnabledLevel(TestLogger.LOG_LEVEL_DEBUG); context.put("log", log); assertEvalEquals("a", "a$!log.startCapture()#stop('woogie!')b"); Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/StringResourceLoaderRepositoryTestCase.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/StringResourceLoaderRepositoryTestCase.java?rev=1700350&r1=1700349&r2=1700350&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/StringResourceLoaderRepositoryTestCase.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/StringResourceLoaderRepositoryTestCase.java Mon Aug 31 21:06:34 2015 @@ -22,16 +22,17 @@ package org.apache.velocity.test; import java.io.StringWriter; import junit.framework.TestCase; +import org.slf4j.impl.SimpleLogger; import org.apache.velocity.Template; import org.apache.velocity.VelocityContext; import org.apache.velocity.app.Velocity; import org.apache.velocity.app.VelocityEngine; import org.apache.velocity.runtime.RuntimeSingleton; -import org.apache.velocity.runtime.log.SystemLogChute; import org.apache.velocity.runtime.resource.loader.StringResourceLoader; import org.apache.velocity.runtime.resource.util.StringResourceRepository; import org.apache.velocity.runtime.resource.util.StringResourceRepositoryImpl; +import org.apache.velocity.test.misc.TestLogger; /** * Tests ability to have multiple repositories in the same app. @@ -54,7 +55,7 @@ public class StringResourceLoaderReposit Velocity.setProperty(Velocity.RESOURCE_LOADER, "string"); Velocity.addProperty("string.resource.loader.class", StringResourceLoader.class.getName()); Velocity.addProperty("string.resource.loader.modificationCheckInterval", "1"); - Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS, SystemLogChute.class.getName()); + Velocity.setProperty(Velocity.RUNTIME_LOG_INSTANCE, new TestLogger()); Velocity.init(); StringResourceRepository repo = getRepo(null, null); @@ -71,6 +72,7 @@ public class StringResourceLoaderReposit protected VelocityEngine newStringEngine(String repoName, boolean isStatic) { VelocityEngine engine = new VelocityEngine(); + TestLogger logger = new TestLogger(); engine.setProperty(Velocity.RESOURCE_LOADER, "string"); engine.addProperty("string.resource.loader.class", StringResourceLoader.class.getName()); if (repoName != null) @@ -82,7 +84,7 @@ public class StringResourceLoaderReposit engine.addProperty("string.resource.loader.repository.static", "false"); } engine.addProperty("string.resource.loader.modificationCheckInterval", "1"); - engine.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS, SystemLogChute.class.getName()); + engine.setProperty(Velocity.RUNTIME_LOG_INSTANCE, logger); return engine; } Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/StringResourceLoaderTestCase.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/StringResourceLoaderTestCase.java?rev=1700350&r1=1700349&r2=1700350&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/StringResourceLoaderTestCase.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/StringResourceLoaderTestCase.java Mon Aug 31 21:06:34 2015 @@ -31,7 +31,7 @@ import org.apache.velocity.Template; import org.apache.velocity.VelocityContext; import org.apache.velocity.app.Velocity; import org.apache.velocity.runtime.RuntimeSingleton; -import org.apache.velocity.test.misc.TestLogChute; +import org.apache.velocity.test.misc.TestLogger; import org.apache.velocity.runtime.resource.loader.StringResourceLoader; /** @@ -77,7 +77,7 @@ public class StringResourceLoaderTestCas Velocity.addProperty("string.resource.loader.modificationCheckInterval", "1"); // Silence the logger. - Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS, TestLogChute.class.getName()); + Velocity.setProperty(Velocity.RUNTIME_LOG_INSTANCE, new TestLogger()); Velocity.init(); } Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/TemplateTestCase.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/TemplateTestCase.java?rev=1700350&r1=1700349&r2=1700350&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/TemplateTestCase.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/TemplateTestCase.java Mon Aug 31 21:06:34 2015 @@ -34,7 +34,7 @@ import org.apache.velocity.app.FieldMeth import org.apache.velocity.app.Velocity; import org.apache.velocity.runtime.RuntimeConstants; import org.apache.velocity.runtime.RuntimeSingleton; -import org.apache.velocity.test.misc.TestLogChute; +import org.apache.velocity.test.misc.TestLogger; import org.apache.velocity.test.provider.BoolObj; import org.apache.velocity.test.provider.NullToStringObject; import org.apache.velocity.test.provider.TestNumber; @@ -111,7 +111,7 @@ public class TemplateTestCase extends Ba Velocity.FILE_RESOURCE_LOADER_PATH, FILE_RESOURCE_LOADER_PATH); Velocity.setProperty( - Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS, TestLogChute.class.getName()); + Velocity.RUNTIME_LOG_INSTANCE, new TestLogger()); Velocity.init(); Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/TemplateTestSuite.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/TemplateTestSuite.java?rev=1700350&r1=1700349&r2=1700350&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/TemplateTestSuite.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/TemplateTestSuite.java Mon Aug 31 21:06:34 2015 @@ -25,7 +25,6 @@ import java.util.Properties; import junit.framework.TestSuite; import org.apache.velocity.app.Velocity; -import org.apache.velocity.test.misc.TestLogChute; /** * Test suite for Templates. Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/URLResourceLoaderTimeoutTestCase.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/URLResourceLoaderTimeoutTestCase.java?rev=1700350&r1=1700349&r2=1700350&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/URLResourceLoaderTimeoutTestCase.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/URLResourceLoaderTimeoutTestCase.java Mon Aug 31 21:06:34 2015 @@ -21,7 +21,7 @@ package org.apache.velocity.test; import org.apache.velocity.runtime.RuntimeConstants; import org.apache.velocity.runtime.resource.loader.URLResourceLoader; -import org.apache.velocity.test.misc.TestLogChute; +import org.apache.velocity.test.misc.TestLogger; /** * This class tests support for custom timeouts in URLResourceLoader. @@ -41,7 +41,7 @@ public class URLResourceLoaderTimeoutTes isJava5plus = false; } } - private TestLogChute logger = new TestLogChute(); + private TestLogger logger = new TestLogger(); private URLResourceLoader loader = new URLResourceLoader(); private int timeout = 2000; @@ -59,7 +59,7 @@ public class URLResourceLoaderTimeoutTes // actual instance of logger logger.on(); - engine.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM, logger); + engine.setProperty(RuntimeConstants.RUNTIME_LOG_INSTANCE, logger); engine.setProperty("runtime.log.logsystem.test.level", "debug"); engine.init(); } Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/VMLibraryTestCase.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/VMLibraryTestCase.java?rev=1700350&r1=1700349&r2=1700350&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/VMLibraryTestCase.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/VMLibraryTestCase.java Mon Aug 31 21:06:34 2015 @@ -34,7 +34,7 @@ import org.apache.velocity.VelocityConte import org.apache.velocity.app.Velocity; import org.apache.velocity.app.VelocityEngine; import org.apache.velocity.runtime.RuntimeConstants; -import org.apache.velocity.test.misc.TestLogChute; +import org.apache.velocity.test.misc.TestLogger; /** * Macro library inclution via the Template.merge method is tested using this @@ -77,7 +77,7 @@ public class VMLibraryTestCase extends B ve1.setProperty("file.resource.loader.cache", Boolean.TRUE); ve1.setProperty( - Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS, TestLogChute.class.getName()); + Velocity.RUNTIME_LOG_INSTANCE, new TestLogger()); ve1.setProperty(RuntimeConstants.RESOURCE_LOADER, "file"); ve1.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, @@ -96,7 +96,7 @@ public class VMLibraryTestCase extends B ve2.setProperty("file.resource.loader.cache", Boolean.FALSE); ve2.setProperty( - Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS, TestLogChute.class.getName()); + Velocity.RUNTIME_LOG_INSTANCE, new TestLogger()); ve2.setProperty(RuntimeConstants.RESOURCE_LOADER, "file"); ve2.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/VelocimacroTestCase.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/VelocimacroTestCase.java?rev=1700350&r1=1700349&r2=1700350&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/VelocimacroTestCase.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/VelocimacroTestCase.java Mon Aug 31 21:06:34 2015 @@ -28,7 +28,7 @@ import junit.framework.TestSuite; import org.apache.velocity.VelocityContext; import org.apache.velocity.exception.MacroOverflowException; import org.apache.velocity.app.Velocity; -import org.apache.velocity.test.misc.TestLogChute; +import org.apache.velocity.test.misc.TestLogger; /** * This class tests strange Velocimacro issues. @@ -59,7 +59,7 @@ public class VelocimacroTestCase extends Velocity.setProperty( Velocity.VM_PERM_INLINE_LOCAL, Boolean.TRUE); Velocity.setProperty( Velocity.VM_MAX_DEPTH, new Integer(5)); Velocity.setProperty( - Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS, TestLogChute.class.getName()); + Velocity.RUNTIME_LOG_INSTANCE, new TestLogger()); Velocity.init(); } Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/VelocityAppTestCase.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/VelocityAppTestCase.java?rev=1700350&r1=1700349&r2=1700350&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/VelocityAppTestCase.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/VelocityAppTestCase.java Mon Aug 31 21:06:34 2015 @@ -26,7 +26,7 @@ import junit.framework.TestSuite; import org.apache.velocity.VelocityContext; import org.apache.velocity.app.Velocity; -import org.apache.velocity.test.misc.TestLogChute; +import org.apache.velocity.test.misc.TestLogger; /** * This class is intended to test the app.Velocity.java class. @@ -53,7 +53,7 @@ public class VelocityAppTestCase extends Velocity.FILE_RESOURCE_LOADER_PATH, FILE_RESOURCE_LOADER_PATH); Velocity.setProperty( - Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS, TestLogChute.class.getName()); + Velocity.RUNTIME_LOG_INSTANCE, new TestLogger()); Velocity.init(); } Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/issues/VelTools66TestCase.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/issues/VelTools66TestCase.java?rev=1700350&r1=1700349&r2=1700350&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/issues/VelTools66TestCase.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/issues/VelTools66TestCase.java Mon Aug 31 21:06:34 2015 @@ -28,7 +28,7 @@ import junit.framework.TestSuite; import org.apache.velocity.app.Velocity; import org.apache.velocity.runtime.RuntimeInstance; -import org.apache.velocity.test.misc.TestLogChute; +import org.apache.velocity.test.misc.TestLogger; import org.apache.velocity.test.BaseTestCase; import org.apache.velocity.util.introspection.Introspector; @@ -55,7 +55,7 @@ public class VelTools66TestCase throws Exception { Velocity.setProperty( - Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS, TestLogChute.class.getName()); + Velocity.RUNTIME_LOG_INSTANCE, new TestLogger()); Velocity.init(); System.setSecurityManager(new TestSecurityManager()); Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/issues/Velocity537TestCase.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/issues/Velocity537TestCase.java?rev=1700350&r1=1700349&r2=1700350&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/issues/Velocity537TestCase.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/issues/Velocity537TestCase.java Mon Aug 31 21:06:34 2015 @@ -24,7 +24,7 @@ import org.apache.velocity.VelocityConte import org.apache.velocity.app.Velocity; import org.apache.velocity.app.VelocityEngine; import org.apache.velocity.test.BaseTestCase; -import org.apache.velocity.test.misc.TestLogChute; +import org.apache.velocity.test.misc.TestLogger; /** * Test Case for <a href="https://issues.apache.org/jira/browse/VELOCITY-537">Velocity Issue 537</a>. @@ -75,7 +75,7 @@ public class Velocity537TestCase extends velocityEngine = new VelocityEngine(); velocityEngine.addProperty(Velocity.FILE_RESOURCE_LOADER_PATH, TEMPLATE_DIR); - velocityEngine.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS, TestLogChute.class.getName()); + velocityEngine.setProperty(Velocity.RUNTIME_LOG_INSTANCE, new TestLogger()); velocityEngine.init(); } Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/issues/Velocity580TestCase.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/issues/Velocity580TestCase.java?rev=1700350&r1=1700349&r2=1700350&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/issues/Velocity580TestCase.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/issues/Velocity580TestCase.java Mon Aug 31 21:06:34 2015 @@ -23,7 +23,7 @@ import org.apache.velocity.Template; import org.apache.velocity.VelocityContext; import org.apache.velocity.app.Velocity; import org.apache.velocity.runtime.RuntimeSingleton; -import org.apache.velocity.test.misc.TestLogChute; +import org.apache.velocity.test.misc.TestLogger; import org.apache.velocity.test.BaseTestCase; /** @@ -75,7 +75,7 @@ public class Velocity580TestCase extends Velocity.addProperty(Velocity.FILE_RESOURCE_LOADER_PATH, TEMPLATE_DIR); - Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS, TestLogChute.class.getName()); + Velocity.setProperty(Velocity.RUNTIME_LOG_INSTANCE, new TestLogger()); Velocity.init(); } Copied: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/misc/TestLogger.java (from r1700349, velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/misc/TestLogChute.java) URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/misc/TestLogger.java?p2=velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/misc/TestLogger.java&p1=velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/misc/TestLogChute.java&r1=1700349&r2=1700350&rev=1700350&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/misc/TestLogChute.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/misc/TestLogger.java Mon Aug 31 21:06:34 2015 @@ -21,90 +21,122 @@ package org.apache.velocity.test.misc; import java.io.ByteArrayOutputStream; import java.io.PrintStream; + +import org.slf4j.Logger; +import org.slf4j.helpers.FormattingTuple; +import org.slf4j.helpers.MarkerIgnoringBase; +import org.slf4j.helpers.MessageFormatter; +import org.slf4j.spi.LocationAwareLogger; + import org.apache.velocity.runtime.RuntimeServices; -import org.apache.velocity.runtime.log.SystemLogChute; /** - * LogChute implementation that can easily capture output + * Logger implementation that can easily capture output * or suppress it entirely. By default, both capture and suppress * are on. To have this behave like a normal SystemLogChute, * you must turn it on() and stopCapture(). * * @author <a href="mailto:[email protected]">Will Glass-Husain</a> * @author Nathan Bubna + * @author <a href="mailto:[email protected]">Claude Brisson</a> * @version $Id$ */ -public class TestLogChute extends SystemLogChute +public class TestLogger extends MarkerIgnoringBase { - public static final String TEST_LOGGER_LEVEL = "runtime.log.logsystem.test.level"; - private ByteArrayOutputStream log; private PrintStream systemDotIn; + private boolean suppress = true; private boolean capture = true; + private int enabledLevel = LOG_LEVEL_INFO; - public TestLogChute() + public TestLogger() { - log = new ByteArrayOutputStream(); - systemDotIn = new PrintStream(log, true); + this(true, true); } - public TestLogChute(boolean suppress, boolean capture) + public TestLogger(boolean suppress, boolean capture) { - this(); this.suppress = suppress; this.capture = capture; + if (suppress) + { + off(); + } + else if (capture) + { + startCapture(); + } } - public void init(RuntimeServices rs) + public static final int LOG_LEVEL_TRACE = LocationAwareLogger.TRACE_INT; + public static final int LOG_LEVEL_DEBUG = LocationAwareLogger.DEBUG_INT; + public static final int LOG_LEVEL_INFO = LocationAwareLogger.INFO_INT; + public static final int LOG_LEVEL_WARN = LocationAwareLogger.WARN_INT; + public static final int LOG_LEVEL_ERROR = LocationAwareLogger.ERROR_INT; + + private static int stringToLevel(String levelStr) { - super.init(rs); + if ("trace".equalsIgnoreCase(levelStr)) return LOG_LEVEL_TRACE; + else if ("debug".equalsIgnoreCase(levelStr)) return LOG_LEVEL_DEBUG; + else if ("info".equalsIgnoreCase(levelStr)) return LOG_LEVEL_INFO; + else if ("warn".equalsIgnoreCase(levelStr)) return LOG_LEVEL_WARN; + else if ("error".equalsIgnoreCase(levelStr)) return LOG_LEVEL_ERROR; + // assume INFO by default + return LOG_LEVEL_INFO; + } - String level = rs.getString(TEST_LOGGER_LEVEL); - if (level != null) - { - setEnabledLevel(toLevel(level)); - } + private static String getPrefix(int level) + { + if (level <= LOG_LEVEL_TRACE) return " [trace] "; + else if (level <= LOG_LEVEL_DEBUG) return " [debug] "; + else if (level <= LOG_LEVEL_INFO) return " [info] "; + else if (level <= LOG_LEVEL_WARN) return " [warn] "; + else return " [error]"; } - public void on() + public synchronized void on() { - suppress = false; + if (suppress) + { + suppress = false; + if (capture) + { + startCapture(); + } + } } - public void off() + public synchronized void off() { suppress = true; } - public void startCapture() + public synchronized void startCapture() { capture = true; + if (!suppress) + { + log = new ByteArrayOutputStream(); + systemDotIn = new PrintStream(log, true); + } } - public void stopCapture() + public synchronized void stopCapture() { capture = false; } - public boolean isLevelEnabled(int level) + public void setEnabledLevel(int level) { - return (!suppress || capture) && super.isLevelEnabled(level); + enabledLevel = level; } - - protected void write(PrintStream ps, String prefix, String message, Throwable t) + public boolean isLevelEnabled(int level) { - if (capture) - { - super.write(systemDotIn, prefix, message, t); - } - else - { - super.write(ps, prefix, message, t); - } + return !suppress && level >= enabledLevel; } - + /** * Return the captured log messages to date. * @return log messages @@ -114,4 +146,188 @@ public class TestLogChute extends System return log.toString(); } + private synchronized void log(int level, String msg, Throwable t) + { + if(!suppress && level >= enabledLevel) + { + PrintStream writer = capture ? systemDotIn : System.err; + writer.print(getPrefix(enabledLevel)); + writer.println(msg); + if (t != null) + { + writer.println(t.getMessage()); + t.printStackTrace(writer); + } + writer.flush(); + } + } + + /** + * Logging API + */ + + public boolean isTraceEnabled() + { + return isLevelEnabled(LOG_LEVEL_TRACE); + } + + public void trace(String msg) + { + log(LOG_LEVEL_TRACE, msg, null); + } + + public void trace(String format, Object arg) + { + FormattingTuple ft = MessageFormatter.format(format, arg); + log(LOG_LEVEL_TRACE, ft.getMessage(), ft.getThrowable()); + } + + public void trace(String format, Object arg1, Object arg2) + { + FormattingTuple ft = MessageFormatter.format(format, arg1, arg2); + log(LOG_LEVEL_TRACE, ft.getMessage(), ft.getThrowable()); + } + + public void trace(String format, Object[] argArray) + { + FormattingTuple ft = MessageFormatter.arrayFormat(format, argArray); + log(LOG_LEVEL_TRACE, ft.getMessage(), ft.getThrowable()); + } + + public void trace(String msg, Throwable t) + { + log(LOG_LEVEL_TRACE, msg, t); + } + + public boolean isDebugEnabled() + { + return isLevelEnabled(LOG_LEVEL_DEBUG); + } + + public void debug(String msg) + { + log(LOG_LEVEL_DEBUG, msg, null); + } + + public void debug(String format, Object arg) + { + FormattingTuple ft = MessageFormatter.format(format, arg); + log(LOG_LEVEL_DEBUG, ft.getMessage(), ft.getThrowable()); + } + + public void debug(String format, Object arg1, Object arg2) + { + FormattingTuple ft = MessageFormatter.format(format, arg1, arg2); + log(LOG_LEVEL_DEBUG, ft.getMessage(), ft.getThrowable()); + } + + public void debug(String format, Object[] argArray) + { + FormattingTuple ft = MessageFormatter.arrayFormat(format, argArray); + log(LOG_LEVEL_DEBUG, ft.getMessage(), ft.getThrowable()); + } + + public void debug(String msg, Throwable t) + { + log(LOG_LEVEL_DEBUG, msg, t); + } + + public boolean isInfoEnabled() + { + return isLevelEnabled(LOG_LEVEL_INFO); + } + + public void info(String msg) + { + log(LOG_LEVEL_INFO, msg, null); + } + + public void info(String format, Object arg) + { + FormattingTuple ft = MessageFormatter.format(format, arg); + log(LOG_LEVEL_INFO, ft.getMessage(), ft.getThrowable()); + } + + public void info(String format, Object arg1, Object arg2) + { + FormattingTuple ft = MessageFormatter.format(format, arg1, arg2); + log(LOG_LEVEL_INFO, ft.getMessage(), ft.getThrowable()); + } + + public void info(String format, Object[] argArray) + { + FormattingTuple ft = MessageFormatter.arrayFormat(format, argArray); + log(LOG_LEVEL_INFO, ft.getMessage(), ft.getThrowable()); + } + + public void info(String msg, Throwable t) + { + log(LOG_LEVEL_INFO, msg, t); + } + + public boolean isWarnEnabled() + { + return isLevelEnabled(LOG_LEVEL_WARN); + } + + public void warn(String msg) + { + log(LOG_LEVEL_WARN, msg, null); + } + + public void warn(String format, Object arg) + { + FormattingTuple ft = MessageFormatter.format(format, arg); + log(LOG_LEVEL_WARN, ft.getMessage(), ft.getThrowable()); + } + + public void warn(String format, Object arg1, Object arg2) + { + FormattingTuple ft = MessageFormatter.format(format, arg1, arg2); + log(LOG_LEVEL_WARN, ft.getMessage(), ft.getThrowable()); + } + + public void warn(String format, Object[] argArray) + { + FormattingTuple ft = MessageFormatter.arrayFormat(format, argArray); + log(LOG_LEVEL_WARN, ft.getMessage(), ft.getThrowable()); + } + + public void warn(String msg, Throwable t) + { + log(LOG_LEVEL_WARN, msg, t); + } + + public boolean isErrorEnabled() + { + return isLevelEnabled(LOG_LEVEL_ERROR); + } + + public void error(String msg) + { + log(LOG_LEVEL_ERROR, msg, null); + } + + public void error(String format, Object arg) + { + FormattingTuple ft = MessageFormatter.format(format, arg); + log(LOG_LEVEL_ERROR, ft.getMessage(), ft.getThrowable()); + } + + public void error(String format, Object arg1, Object arg2) + { + FormattingTuple ft = MessageFormatter.format(format, arg1, arg2); + log(LOG_LEVEL_ERROR, ft.getMessage(), ft.getThrowable()); + } + + public void error(String format, Object[] argArray) + { + FormattingTuple ft = MessageFormatter.arrayFormat(format, argArray); + log(LOG_LEVEL_ERROR, ft.getMessage(), ft.getThrowable()); + } + + public void error(String msg, Throwable t) + { + log(LOG_LEVEL_ERROR, msg, t); + } } Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/sql/DataSourceResourceLoaderTestCase.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/sql/DataSourceResourceLoaderTestCase.java?rev=1700350&r1=1700349&r2=1700350&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/sql/DataSourceResourceLoaderTestCase.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/sql/DataSourceResourceLoaderTestCase.java Mon Aug 31 21:06:34 2015 @@ -33,7 +33,7 @@ import junit.framework.TestSuite; import org.apache.velocity.Template; import org.apache.velocity.VelocityContext; import org.apache.velocity.app.Velocity; -import org.apache.velocity.test.misc.TestLogChute; +import org.apache.velocity.test.misc.TestLogger; import org.apache.velocity.runtime.RuntimeSingleton; import org.apache.velocity.runtime.resource.loader.DataSourceResourceLoader; @@ -111,7 +111,7 @@ public class DataSourceResourceLoaderTes Velocity.setProperty( "ds.resource.loader.resource.timestampcolumn", "timestamp"); Velocity.setProperty( - Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS, TestLogChute.class.getName()); + Velocity.RUNTIME_LOG_INSTANCE, new TestLogger()); Velocity.init(); } Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/util/introspection/ChainedUberspectorsTestCase.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/util/introspection/ChainedUberspectorsTestCase.java?rev=1700350&r1=1700349&r2=1700350&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/util/introspection/ChainedUberspectorsTestCase.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/util/introspection/ChainedUberspectorsTestCase.java Mon Aug 31 21:06:34 2015 @@ -22,7 +22,7 @@ package org.apache.velocity.test.util.in import junit.framework.Test; import junit.framework.TestSuite; import org.apache.velocity.app.Velocity; -import org.apache.velocity.test.misc.TestLogChute; +import org.apache.velocity.test.misc.TestLogger; import org.apache.velocity.util.introspection.*; import org.apache.velocity.test.BaseTestCase; import org.apache.velocity.VelocityContext; @@ -49,7 +49,7 @@ public class ChainedUberspectorsTestCase throws Exception { Velocity.reset(); - Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS, TestLogChute.class.getName()); + Velocity.setProperty(Velocity.RUNTIME_LOG_INSTANCE, new TestLogger()); Velocity.addProperty(Velocity.UBERSPECT_CLASSNAME,"org.apache.velocity.util.introspection.UberspectImpl"); Velocity.addProperty(Velocity.UBERSPECT_CLASSNAME,"org.apache.velocity.test.util.introspection.ChainedUberspectorsTestCase$ChainedUberspector"); Velocity.addProperty(Velocity.UBERSPECT_CLASSNAME,"org.apache.velocity.test.util.introspection.ChainedUberspectorsTestCase$LinkedUberspector"); Modified: velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/util/introspection/ClassMapTestCase.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/util/introspection/ClassMapTestCase.java?rev=1700350&r1=1700349&r2=1700350&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/util/introspection/ClassMapTestCase.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/test/java/org/apache/velocity/test/util/introspection/ClassMapTestCase.java Mon Aug 31 21:06:34 2015 @@ -21,10 +21,9 @@ package org.apache.velocity.test.util.in import junit.framework.Test; import junit.framework.TestSuite; - +import org.slf4j.Logger; import org.apache.velocity.app.Velocity; -import org.apache.velocity.runtime.log.Log; -import org.apache.velocity.test.misc.TestLogChute; +import org.apache.velocity.test.misc.TestLogger; import org.apache.velocity.test.BaseTestCase; import org.apache.velocity.util.introspection.ClassMap; @@ -48,9 +47,7 @@ public class ClassMapTestCase public void setUp() throws Exception { - Velocity.setProperty( - Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS, TestLogChute.class.getName()); - + Velocity.setProperty(Velocity.RUNTIME_LOG_INSTANCE, new TestLogger()); Velocity.init(); } @@ -61,7 +58,7 @@ public class ClassMapTestCase public void testPrimitives() throws Exception { - Log log = Velocity.getLog(); + Logger log = Velocity.getLog(); ClassMap c = new ClassMap(TestClassMap.class, log); assertNotNull(c.findMethod("setBoolean", new Object[] { Boolean.TRUE })); Modified: velocity/engine/trunk/velocity-engine-examples/src/etc/README.txt URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-examples/src/etc/README.txt?rev=1700350&r1=1700349&r2=1700350&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-examples/src/etc/README.txt (original) +++ velocity/engine/trunk/velocity-engine-examples/src/etc/README.txt Mon Aug 31 21:06:34 2015 @@ -64,11 +64,6 @@ This is a demonstration of 2 different c script. - a context implementation that uses a TreeMap for storage. Very simple. -logger_example --------------- -This is a toy program to show how any class can be used as a logging -facility with Velocity. - xmlapp_example -------------- This is simple example that demonstrates direct access of XML data via Modified: velocity/engine/trunk/velocity-engine-examples/src/main/java/org/apache/velocity/example/EventExample.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-examples/src/main/java/org/apache/velocity/example/EventExample.java?rev=1700350&r1=1700349&r2=1700350&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-examples/src/main/java/org/apache/velocity/example/EventExample.java (original) +++ velocity/engine/trunk/velocity-engine-examples/src/main/java/org/apache/velocity/example/EventExample.java Mon Aug 31 21:06:34 2015 @@ -19,7 +19,9 @@ package org.apache.velocity.example; */ import java.io.StringWriter; - +import org.slf4j.helpers.FormattingTuple; +import org.slf4j.helpers.MarkerIgnoringBase; +import org.slf4j.helpers.MessageFormatter; import org.apache.velocity.VelocityContext; import org.apache.velocity.app.Velocity; import org.apache.velocity.app.event.EventCartridge; @@ -28,7 +30,6 @@ import org.apache.velocity.app.event.Ref import org.apache.velocity.exception.MethodInvocationException; import org.apache.velocity.exception.ParseErrorException; import org.apache.velocity.runtime.RuntimeServices; -import org.apache.velocity.runtime.log.LogChute; /** * This class is a simple demonstration of how the event handling @@ -40,10 +41,9 @@ import org.apache.velocity.runtime.log.L * @version $Id$ */ -public class EventExample implements ReferenceInsertionEventHandler, - MethodExceptionEventHandler, LogChute +public class EventExample extends MarkerIgnoringBase + implements ReferenceInsertionEventHandler, MethodExceptionEventHandler { - private boolean logOutput = false; private boolean exceptionSwitch = false; @@ -57,11 +57,11 @@ public class EventExample implements Ref try { /* - * this class implements the LogSystem interface, so we + * this class implements the Logger interface, so we * can use it as a logger for Velocity */ - Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM, this ); + Velocity.setProperty(Velocity.RUNTIME_LOG_INSTANCE, this ); Velocity.init(); } catch(Exception e) @@ -292,14 +292,9 @@ public class EventExample implements Ref throw new RuntimeException(e); } - /** - * Required init method for LogSystem - * to get access to RuntimeServices - */ - public void init( RuntimeServices rs ) - { - return; - } + /** + * Our own logging towards System.out + */ /** * This just prints the message and level to System.out. @@ -327,6 +322,19 @@ public class EventExample implements Ref } /** + * This prints the level and formatted message to + * System.out. + */ + public void formatAndLog(int level, String format, Object... arguments) + { + if (logOutput) + { + FormattingTuple tp = MessageFormatter.arrayFormat(format, arguments); + log(level, tp.getMessage()); + } + } + + /** * This always returns true because logging levels can't be disabled in * this impl. */ @@ -334,4 +342,167 @@ public class EventExample implements Ref { return true; } + + public static final int LOG_LEVEL_TRACE = 1; + public static final int LOG_LEVEL_DEBUG = 2; + public static final int LOG_LEVEL_INFO = 3; + public static final int LOG_LEVEL_WARN = 4; + public static final int LOG_LEVEL_ERROR = 5; + + /** + * Required init methods for Logger interface + */ + + public String getName() + { + return "EventExample"; + } + + public boolean isTraceEnabled() { + return isLevelEnabled(LOG_LEVEL_TRACE); + } + + public void trace(String msg) { + log(LOG_LEVEL_TRACE, msg); + } + + public void trace(String format, Object param1) + { + formatAndLog(LOG_LEVEL_TRACE, format, param1); + } + + public void trace(String format, Object param1, Object param2) + { + formatAndLog(LOG_LEVEL_TRACE, format, param1, param2); + } + + public void trace(String format, Object... argArray) + { + formatAndLog(LOG_LEVEL_TRACE, format, argArray); + } + + public void trace(String msg, Throwable t) + { + log(LOG_LEVEL_TRACE, msg, t); + } + + public boolean isDebugEnabled() + { + return isLevelEnabled(LOG_LEVEL_DEBUG); + } + + public void debug(String msg) + { + log(LOG_LEVEL_DEBUG, msg); + } + + public void debug(String format, Object param1) + { + formatAndLog(LOG_LEVEL_DEBUG, format, param1); + } + + public void debug(String format, Object param1, Object param2) + { + formatAndLog(LOG_LEVEL_DEBUG, format, param1, param2); + } + + public void debug(String format, Object... argArray) + { + formatAndLog(LOG_LEVEL_DEBUG, format, argArray); + } + + public void debug(String msg, Throwable t) + { + log(LOG_LEVEL_DEBUG, msg, t); + } + + public boolean isInfoEnabled() + { + return isLevelEnabled(LOG_LEVEL_INFO); + } + + public void info(String msg) + { + log(LOG_LEVEL_INFO, msg); + } + + public void info(String format, Object arg) + { + formatAndLog(LOG_LEVEL_INFO, format, arg); + } + + public void info(String format, Object arg1, Object arg2) + { + formatAndLog(LOG_LEVEL_INFO, format, arg1, arg2); + } + + public void info(String format, Object... argArray) + { + formatAndLog(LOG_LEVEL_INFO, format, argArray); + } + + public void info(String msg, Throwable t) + { + log(LOG_LEVEL_INFO, msg, t); + } + + public boolean isWarnEnabled() + { + return isLevelEnabled(LOG_LEVEL_WARN); + } + + public void warn(String msg) + { + log(LOG_LEVEL_WARN, msg); + } + + public void warn(String format, Object arg) + { + formatAndLog(LOG_LEVEL_WARN, format, arg); + } + + public void warn(String format, Object arg1, Object arg2) + { + formatAndLog(LOG_LEVEL_WARN, format, arg1, arg2); + } + + public void warn(String format, Object... argArray) + { + formatAndLog(LOG_LEVEL_WARN, format, argArray); + } + + public void warn(String msg, Throwable t) + { + log(LOG_LEVEL_WARN, msg, t); + } + + public boolean isErrorEnabled() + { + return isLevelEnabled(LOG_LEVEL_ERROR); + } + + public void error(String msg) + { + log(LOG_LEVEL_ERROR, msg); + } + + public void error(String format, Object arg) + { + formatAndLog(LOG_LEVEL_ERROR, format, arg); + } + + public void error(String format, Object arg1, Object arg2) + { + formatAndLog(LOG_LEVEL_ERROR, format, arg1, arg2); + } + + public void error(String format, Object... argArray) + { + formatAndLog(LOG_LEVEL_ERROR, format, argArray); + } + + public void error(String msg, Throwable t) + { + log(LOG_LEVEL_ERROR, msg, t); + } }
