01: /*
02: * Copyright 2002-2005 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.springframework.ui.velocity;
18:
19: import org.apache.commons.logging.Log;
20: import org.apache.commons.logging.LogFactory;
21: import org.apache.velocity.app.VelocityEngine;
22: import org.apache.velocity.runtime.RuntimeServices;
23: import org.apache.velocity.runtime.log.LogSystem;
24:
25: /**
26: * Velocity LogSystem implementation for Jakarta Commons Logging.
27: * Used by VelocityConfigurer to redirect log output.
28: *
29: * @author Juergen Hoeller
30: * @since 07.08.2003
31: * @see VelocityEngineFactoryBean
32: */
33: public class CommonsLoggingLogSystem implements LogSystem {
34:
35: private static final Log logger = LogFactory
36: .getLog(VelocityEngine.class);
37:
38: public void init(RuntimeServices runtimeServices) {
39: }
40:
41: public void logVelocityMessage(int type, String msg) {
42: switch (type) {
43: case ERROR_ID:
44: logger.error(msg);
45: break;
46: case WARN_ID:
47: logger.warn(msg);
48: break;
49: case INFO_ID:
50: logger.info(msg);
51: break;
52: case DEBUG_ID:
53: logger.debug(msg);
54: break;
55: }
56: }
57:
58: }
|