1 /**
2 *
3 * Copyright 2003-2004 The Apache Software Foundation
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * 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: 355877 $ $Date: 2005-12-10 18:48:27 -0800 (Sat, 10 Dec 2005) $
27 */
28 public final class GeronimoLog implements Log {
29 private final String name;
30 private Log log;
31
32 public GeronimoLog(String name, Log log) {
33 this.name = name;
34 this.log = log;
35 }
36
37 public String 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 message) {
54 log.trace(message);
55 }
56
57 public void trace(Object message, Throwable throwable) {
58 log.trace(message, throwable);
59 }
60
61 public boolean isDebugEnabled() {
62 return log.isDebugEnabled();
63 }
64
65 public void debug(Object message) {
66 log.debug(message);
67 }
68
69 public void debug(Object message, Throwable throwable) {
70 log.debug(message, throwable);
71 }
72
73 public boolean isInfoEnabled() {
74 return log.isInfoEnabled();
75 }
76
77 public void info(Object message) {
78 if(!name.startsWith("/")) {
79 log.info(message);
80 }
81 }
82
83 public void info(Object message, Throwable throwable) {
84 log.info(message, throwable);
85 }
86
87 public boolean isWarnEnabled() {
88 return log.isWarnEnabled();
89 }
90
91 public void warn(Object message) {
92 log.warn(message);
93 }
94
95 public void warn(Object message, Throwable throwable) {
96 log.warn(message, throwable);
97 }
98
99 public boolean isErrorEnabled() {
100 return log.isErrorEnabled();
101 }
102
103 public void error(Object message) {
104 log.error(message);
105 }
106
107 public void error(Object message, Throwable throwable) {
108 log.error(message, throwable);
109 }
110
111 public boolean isFatalEnabled() {
112 return log.isFatalEnabled();
113 }
114
115 public void fatal(Object message) {
116 log.fatal(message);
117 }
118
119 public void fatal(Object message, Throwable throwable) {
120 log.fatal(message, throwable);
121 }
122 }