KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > util > logging > LoggerWrapper


1 /*
2 This software is OSI Certified Open Source Software.
3 OSI Certified is a certification mark of the Open Source Initiative.
4
5 The license (Mozilla version 1.0) can be read at the MMBase site.
6 See http://www.MMBase.org/license
7
8 */

9
10 package org.mmbase.util.logging;
11 import java.util.*;
12
13 /**
14  * Wraps a logger instance. This can be used for static logger instances which might be instatatied
15  * before logging itself is configured. After configurating logging, all static 'wrappers' can then
16  * be called to wrap another logger instance.
17  *
18  * @author Michiel Meeuwissen
19  * @since MMBase-1.7
20  * @version $Id: LoggerWrapper.java,v 1.6 2006/08/30 17:54:00 michiel Exp $
21  **/

22
23 public class LoggerWrapper implements Logger {
24
25     private static final Set wrappers = new HashSet();
26
27
28     // package
29
static Set getWrappers() {
30         return Collections.unmodifiableSet(wrappers);
31     }
32
33     private Logger log;
34     private String JavaDoc name;
35
36     // package
37
LoggerWrapper(Logger log, String JavaDoc name) {
38         this.log = log;
39         this.name = name;
40         wrappers.add(this);
41     }
42
43     // package
44
String JavaDoc getName() {
45         return name;
46     }
47
48     // package
49
Logger setLogger(Logger log) {
50         Logger org = this.log;
51         this.log = log;
52         return org;
53     }
54
55     final public void trace (Object JavaDoc m) {
56         log.trace(m);
57     }
58
59     final public void trace (Object JavaDoc m, Throwable JavaDoc t) {
60         log.trace(m, t);
61     }
62
63     final public void debug (Object JavaDoc m) {
64         log.debug(m);
65     }
66
67     final public void debug (Object JavaDoc m, Throwable JavaDoc t) {
68         log.debug(m, t);
69     }
70
71     final public void service (Object JavaDoc m) {
72         log.service(m);
73     }
74
75     final public void service (Object JavaDoc m, Throwable JavaDoc t) {
76         log.service(m, t);
77     }
78
79     final public void info (Object JavaDoc m) {
80         log.info(m);
81     }
82
83     final public void info (Object JavaDoc m, Throwable JavaDoc t) {
84         log.info(m, t);
85     }
86
87     final public void warn (Object JavaDoc m) {
88         log.warn(m);
89     }
90
91     final public void warn (Object JavaDoc m, Throwable JavaDoc t) {
92         log.warn(m, t);
93     }
94
95     final public void error (Object JavaDoc m) {
96         log.error(m);
97     }
98
99     final public void error (Object JavaDoc m, Throwable JavaDoc t) {
100         log.error(m, t);
101     }
102
103     final public void fatal (Object JavaDoc m) {
104         log.fatal(m);
105     }
106
107     final public void fatal (Object JavaDoc m, Throwable JavaDoc t) {
108         log.fatal(m, t);
109     }
110
111     final public boolean isTraceEnabled() {
112         return log.isTraceEnabled();
113     }
114     
115     final public boolean isDebugEnabled() {
116         return log.isDebugEnabled();
117     }
118
119     final public boolean isServiceEnabled() {
120         return log.isServiceEnabled();
121     }
122
123     final public void setLevel(Level p) {
124         log.setLevel(p);
125     }
126
127 }
128
Popular Tags