KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > kernel > log > GeronimoLog


1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 package org.apache.geronimo.kernel.log;
19
20 import org.apache.commons.logging.Log;
21
22 /**
23  * This log wrapper caches the trace, debug and info enabled flags. The flags are updated
24  * by a single timer task for all logs.
25  *
26  * @version $Rev: 476049 $ $Date: 2006-11-16 23:35:17 -0500 (Thu, 16 Nov 2006) $
27  */

28 public final class GeronimoLog implements Log {
29     private final String JavaDoc name;
30     private Log log;
31
32     public GeronimoLog(String JavaDoc name, Log log) {
33         this.name = name;
34         this.log = log;
35     }
36
37     public String JavaDoc getName() {
38         return name;
39     }
40
41     public Log getLog() {
42         return log;
43     }
44
45     public void setLog(Log log) {
46         this.log = log;
47     }
48
49     public boolean isTraceEnabled() {
50         return log.isTraceEnabled();
51     }
52
53     public void trace(Object JavaDoc message) {
54         log.trace(message);
55     }
56
57     public void trace(Object JavaDoc message, Throwable JavaDoc throwable) {
58         log.trace(message, throwable);
59     }
60
61     public boolean isDebugEnabled() {
62         return log.isDebugEnabled();
63     }
64
65     public void debug(Object JavaDoc message) {
66         log.debug(message);
67     }
68
69     public void debug(Object JavaDoc message, Throwable JavaDoc throwable) {
70         log.debug(message, throwable);
71     }
72
73     public boolean isInfoEnabled() {
74         return log.isInfoEnabled();
75     }
76
77     public void info(Object JavaDoc message) {
78         if(!name.startsWith("/")) { //todo: temporary fix to work around Jetty logging issue
79
log.info(message);
80         }
81     }
82
83     public void info(Object JavaDoc message, Throwable JavaDoc throwable) {
84         log.info(message, throwable);
85     }
86
87     public boolean isWarnEnabled() {
88         return log.isWarnEnabled();
89     }
90
91     public void warn(Object JavaDoc message) {
92         log.warn(message);
93     }
94
95     public void warn(Object JavaDoc message, Throwable JavaDoc throwable) {
96         log.warn(message, throwable);
97     }
98
99     public boolean isErrorEnabled() {
100         return log.isErrorEnabled();
101     }
102
103     public void error(Object JavaDoc message) {
104         log.error(message);
105     }
106
107     public void error(Object JavaDoc message, Throwable JavaDoc throwable) {
108         log.error(message, throwable);
109     }
110
111     public boolean isFatalEnabled() {
112         return log.isFatalEnabled();
113     }
114
115     public void fatal(Object JavaDoc message) {
116         log.fatal(message);
117     }
118
119     public void fatal(Object JavaDoc message, Throwable JavaDoc throwable) {
120         log.fatal(message, throwable);
121     }
122 }
123
Popular Tags