KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > ui > velocity > CommonsLoggingLogSystem


1 /*
2  * Copyright 2002-2005 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.getLog(VelocityEngine.class);
36
37     public void init(RuntimeServices runtimeServices) {
38     }
39
40     public void logVelocityMessage(int type, String JavaDoc msg) {
41         switch (type) {
42             case ERROR_ID:
43                 logger.error(msg);
44                 break;
45             case WARN_ID:
46                 logger.warn(msg);
47                 break;
48             case INFO_ID:
49                 logger.info(msg);
50                 break;
51             case DEBUG_ID:
52                 logger.debug(msg);
53                 break;
54         }
55     }
56
57 }
58
Popular Tags