01: package org.apache.velocity.runtime.log;
02:
03: /*
04: * Licensed to the Apache Software Foundation (ASF) under one
05: * or more contributor license agreements. See the NOTICE file
06: * distributed with this work for additional information
07: * regarding copyright ownership. The ASF licenses this file
08: * to you under the Apache License, Version 2.0 (the
09: * "License"); you may not use this file except in compliance
10: * with the License. You may obtain a copy of the License at
11: *
12: * http://www.apache.org/licenses/LICENSE-2.0
13: *
14: * Unless required by applicable law or agreed to in writing,
15: * software distributed under the License is distributed on an
16: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17: * KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations
19: * under the License.
20: */
21:
22: import org.apache.velocity.runtime.RuntimeServices;
23: import org.apache.velocity.util.StringUtils;
24:
25: /**
26: * Wrapper to make user's custom LogSystem implementations work
27: * with the new LogChute setup.
28: *
29: * @author <a href="mailto:nbubna@apache.org">Nathan Bubna</a>
30: * @version $Id: LogChuteSystem.java 463298 2006-10-12 16:10:32Z henning $
31: */
32: public class LogChuteSystem implements LogChute {
33:
34: private LogSystem logSystem;
35:
36: /**
37: * Only classes in this package should be creating this.
38: * Users should not have to mess with this class.
39: * @param wrapMe
40: */
41: protected LogChuteSystem(LogSystem wrapMe) {
42: this .logSystem = wrapMe;
43: }
44:
45: /**
46: * @see org.apache.velocity.runtime.log.LogChute#init(org.apache.velocity.runtime.RuntimeServices)
47: */
48: public void init(RuntimeServices rs) throws Exception {
49: logSystem.init(rs);
50: }
51:
52: /**
53: * @see org.apache.velocity.runtime.log.LogChute#log(int, java.lang.String)
54: */
55: public void log(int level, String message) {
56: logSystem.logVelocityMessage(level, message);
57: }
58:
59: /**
60: * First passes off the message at the specified level,
61: * then passes off stack trace of the Throwable as a
62: * 2nd message at the same level.
63: * @param level
64: * @param message
65: * @param t
66: */
67: public void log(int level, String message, Throwable t) {
68: logSystem.logVelocityMessage(level, message);
69: logSystem.logVelocityMessage(level, StringUtils.stackTrace(t));
70: }
71:
72: /**
73: * @see org.apache.velocity.runtime.log.LogChute#isLevelEnabled(int)
74: */
75: public boolean isLevelEnabled(int level) {
76: return true;
77: }
78:
79: }
|