1 package org.apache.jetspeed.services.logging;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 import org.apache.turbine.util.RunData;
21 import org.apache.turbine.services.logging.Logger;
22 import org.apache.turbine.services.logging.LoggingConfig;
23
24 /***
25 * Classes that implement the Logger interface allows loging.
26 * There is set of standart printing methods (info, debug ...).
27 * This is a wrapper for the commons Log object.
28 *
29 * @author <a href="mailto:morciuch@apache.org">Mark Orciuch</a>
30 * @author <a href="mailto:harald@ommang.com">Harald Ommang</a>
31 * @version $Id: BaseLogger.java,v 1.3 2004/02/23 03:33:29 jford Exp $
32 */
33 public class BaseLogger implements Logger
34 {
35 /***
36 * Reference to commons logger
37 */
38 private JetspeedLogger log = null;
39
40 /***
41 * Current log level for logger
42 */
43 private int logLevel;
44
45 /***
46 * Name of the logger
47 */
48 private String name;
49
50 /***
51 * Parametrized constructor
52 *
53 * @param log
54 */
55 public BaseLogger(JetspeedLogger log)
56 {
57 this.log = log;
58 }
59
60 /***
61 * name of the logger
62 *
63 * @return log name
64 */
65 public String getName()
66 {
67 return this.name;
68 }
69
70 /***
71 * Setings the name
72 *
73 * @param logName
74 */
75 public void setName(String logName)
76 {
77 this.name = logName;
78 }
79
80 /***
81 * Reference to logger
82 *
83 * @return JetspeedLogger
84 */
85 public JetspeedLogger getLog()
86 {
87 return this.log;
88 }
89
90 /***
91 * Sets reference to JetspeedLogger
92 *
93 * @param log
94 */
95 public void setLog(JetspeedLogger log)
96 {
97 this.log = log;
98 }
99
100 /***
101 * This method should be implemented by user.
102 * It performs action that are need for deterimne whether
103 * logger was well configured or has any output
104 *
105 * @return true if logger is well configured
106 */
107 public boolean checkLogger()
108 {
109
110 return true;
111 }
112
113
114 /***
115 * This method sets parameters for the logger implementation.
116 * If the implementation cannot handle some type of destination should ignore
117 * that output.
118 *
119 * @param LoggingConfig configuration object for logging
120 */
121 public void init(LoggingConfig loggingConfig)
122 {
123
124 }
125
126 /***
127 * Close all destinations
128 */
129 public void shutdown()
130 {
131
132 }
133
134 /***
135 * Sets log level for the logger
136 *
137 * @param level
138 */
139 public void setLogLevel(int level)
140 {
141 this.logLevel = level;
142 }
143
144 /***
145 * Checks if DEBUG statements are enabled.
146 *
147 * @return true if debug is enabled
148 */
149 public boolean isDebugEnabled()
150 {
151
152 return this.log.isDebugEnabled();
153 }
154
155 /***
156 * Checks if INFO statements are enabled.
157 *
158 * @return true if into is enabled
159 */
160 public boolean isInfoEnabled()
161 {
162
163 return this.log.isInfoEnabled();
164 }
165
166 /***
167 * Checks if WARN statements are enabled.
168 *
169 * @return true if warn is enabled
170 */
171 public boolean isWarnEnabled()
172 {
173
174 return this.log.isWarnEnabled();
175 }
176
177
178 /***
179 * Checks if ERROR statements are enabled.
180 *
181 * @return true if error is enabled
182 */
183 public boolean isErrorEnabled()
184 {
185
186 return this.log.isErrorEnabled();
187 }
188
189 /***
190 * Sets format style for extracting data from RunData
191 *
192 * @param format
193 */
194 public void setFormat(String format)
195 {
196
197 }
198
199 /***
200 * This is a log method with logLevel == DEBUG
201 *
202 * @param message
203 */
204 public void debug(String message)
205 {
206 this.log.debug(message);
207 }
208
209 /***
210 * This is a log method with logLevel == DEBUG
211 *
212 * @param message
213 * @param t
214 */
215 public void debug(String message, Throwable t)
216 {
217 this.log.debug(message, t);
218 }
219
220 /***
221 * This is a log method with logLevel == DEBUG
222 *
223 * @param message
224 * @param data
225 */
226 public void debug(String message, RunData data)
227 {
228 this.log.debug(message);
229 }
230
231 /***
232 * This is a log method with logLevel == DEBUG
233 *
234 * @param message
235 * @param data
236 * @param t
237 */
238 public void debug(String message, RunData data, Throwable t)
239 {
240 this.log.debug(message, t);
241 }
242
243 /***
244 * This is a log method with logLevel == INFO
245 *
246 * @param message
247 */
248 public void info(String message)
249 {
250 this.log.info(message);
251 }
252
253 /***
254 * This is a log method with logLevel == INFO
255 *
256 * @param message
257 * @param t
258 */
259 public void info(String message, Throwable t)
260 {
261 this.log.info(message, t);
262 }
263
264 /***
265 * This is a log method with logLevel == INFO
266 *
267 * @param message
268 * @param data
269 */
270 public void info(String message, RunData data)
271 {
272 this.log.info(message);
273 }
274
275 /***
276 * This is a log method with logLevel == INFO
277 *
278 * @param message
279 * @param data
280 * @param t
281 */
282 public void info(String message, RunData data, Throwable t)
283 {
284 this.log.info(message, t);
285 }
286
287 /***
288 * This is a log method with logLevel == WARN
289 *
290 * @param message
291 */
292 public void warn(String message)
293 {
294 this.log.warn(message);
295 }
296
297 /***
298 * This is a log method with logLevel == WARN
299 *
300 * @param message
301 * @param t
302 */
303 public void warn(String message, Throwable t)
304 {
305 this.log.warn(message, t);
306 }
307
308 /***
309 * This is a log method with logLevel == WARN
310 *
311 * @param message
312 * @param data
313 */
314 public void warn(String message, RunData data)
315 {
316 this.log.warn(message);
317 }
318
319 /***
320 * This is a log method with logLevel == WARN
321 *
322 * @param message
323 * @param data
324 * @param t
325 */
326 public void warn(String message, RunData data, Throwable t)
327 {
328 this.log.warn(message, t);
329 }
330
331 /***
332 * This is a log method with logLevel == ERROR
333 *
334 * @param message
335 */
336 public void error(String message)
337 {
338 this.log.error(message);
339 }
340
341 /***
342 * This is a log method with logLevel == ERROR
343 *
344 * @param message
345 * @param e
346 */
347 public void error(String message, Throwable e)
348 {
349 this.log.error(message, e);
350 }
351
352 /***
353 * This is a log method with logLevel == ERROR
354 *
355 * @param e
356 */
357 public void error(Throwable e)
358 {
359 this.log.error(e);
360 }
361
362 /***
363 * This is a log method with logLevel == ERROR
364 *
365 * @param message
366 * @param data
367 */
368 public void error(String message, RunData data)
369 {
370 this.log.error(message);
371 }
372
373 /***
374 * This is a log method with logLevel == ERROR
375 *
376 * @param message
377 * @param data
378 * @param e
379 */
380 public void error(String message, RunData data, Throwable e)
381 {
382 this.log.error(message, e);
383 }
384 }