KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > snapper > logging > StandardLoggingManager


1 package org.enhydra.snapper.logging;
2
3 import java.util.Properties JavaDoc;
4
5 import org.enhydra.snapper.api.RootException;
6
7 import org.apache.log4j.Logger;
8 import org.apache.log4j.PropertyConfigurator;
9
10 /**
11  * Implementation of LoggingManager interface.
12  *
13  * @author Sasa Bojanic
14  * @author Tanja Jovanovic
15  * @author Igor Smirnov
16  */

17 public class StandardLoggingManager implements org.enhydra.snapper.api.logging.LoggingManager {
18    
19    private static final String JavaDoc defaultLogChannel="Snapper";
20
21
22    /**
23     * Configures StandardLoggingManager.
24     *
25     * @param cus an instance of CallbackUtilities used to get
26     * properties for configuring logging in Shark.
27     */

28    public void configure (Properties JavaDoc prop) {
29       PropertyConfigurator.configure(prop);
30    }
31
32    //////////////////////////////////////////////////////////////////
33
// LoggingManager API implementation
34
//////////////////////////////////////////////////////////////////
35

36    /**
37     * Log a message object with the <i>ERROR</i> Level.
38     *
39     * @param msg the message to log.
40     *
41     */

42    public void error (String JavaDoc msg) {
43       error(defaultLogChannel,msg);
44    }
45
46    /**
47     * Log a message object with the <i>ERROR</i> Level.
48     *
49     * @param msg the message to log.
50     * @param ex the exception to log, including its stack trace.
51     *
52     */

53    public void error (String JavaDoc msg,RootException ex) {
54       error(defaultLogChannel,msg,ex);
55    }
56
57    /**
58     * Log a message object with the <i>ERROR</i> Level.
59     *
60     * @param channel the log channel to be used for logging.
61     * @param msg the message to log.
62     *
63     */

64    public void error (String JavaDoc channel,String JavaDoc msg) {
65       Logger logger=Logger.getLogger(channel);
66       if (logger!=null)
67          logger.error(msg);
68      
69          
70    }
71
72    /**
73     * Log a message object with the <i>ERROR</i> Level.
74     *
75     * @param channel the log channel to be used for logging.
76     * @param msg the message to log.
77     * @param ex the exception to log, including its stack trace.
78     *
79     */

80    public void error (String JavaDoc channel,String JavaDoc msg,RootException ex){
81       Logger logger=Logger.getLogger(channel);
82       if (logger!=null)
83          logger.error(msg,ex);
84      
85    }
86
87    /**
88     * Log a message object with the <i>WARN</i> Level.
89     *
90     * @param msg the message to log.
91     *
92     */

93    public void warn (String JavaDoc msg) {
94       warn(defaultLogChannel,msg);
95    }
96
97    /**
98     * Log a message object with the <i>WARN</i> Level.
99     *
100     * @param msg the message to log.
101     * @param ex the exception to log, including its stack trace.
102     *
103     */

104    public void warn (String JavaDoc msg,RootException ex) {
105       warn(defaultLogChannel,msg,ex);
106    }
107
108    /**
109     * Log a message object with the <i>WARN</i> Level.
110     *
111     * @param channel the log channel to be used for logging.
112     * @param msg the message to log.
113     *
114     */

115    public void warn (String JavaDoc channel,String JavaDoc msg) {
116       Logger logger=Logger.getLogger(channel);
117       if (logger!=null)
118          logger.warn(msg);
119      
120    }
121
122    /**
123     * Log a message object with the <i>WARN</i> Level.
124     *
125     * @param channel the log channel to be used for logging.
126     * @param msg the message to log.
127     * @param ex the exception to log, including its stack trace.
128     *
129     */

130    public void warn (String JavaDoc channel,String JavaDoc msg,RootException ex) {
131       Logger logger=Logger.getLogger(channel);
132       if (logger!=null)
133          logger.warn(msg,ex);
134       
135    }
136
137    /**
138     * Log a message object with the <i>INFO</i> Level.
139     *
140     * @param msg the message to log.
141     *
142     */

143    public void info (String JavaDoc msg) {
144       info(defaultLogChannel,msg);
145    }
146
147    /**
148     * Log a message object with the <i>INFO</i> Level.
149     *
150     * @param msg the message to log.
151     * @param ex the exception to log, including its stack trace.
152     *
153     */

154    public void info (String JavaDoc msg,RootException ex) {
155       info(defaultLogChannel,msg,ex);
156    }
157
158    /**
159     * Log a message object with the <i>INFO</i> Level.
160     *
161     * @param channel the log channel to be used for logging.
162     * @param msg the message to log.
163     *
164     */

165    public void info (String JavaDoc channel,String JavaDoc msg) {
166       Logger logger=Logger.getLogger(channel);
167       if (logger!=null)
168          logger.info(msg);
169      
170    }
171
172    /**
173     * Log a message object with the <i>INFO</i> Level.
174     *
175     * @param channel the log channel to be used for logging.
176     * @param msg the message to log.
177     * @param ex the exception to log, including its stack trace.
178     *
179     */

180    public void info (String JavaDoc channel,String JavaDoc msg,RootException ex) {
181       Logger logger=Logger.getLogger(channel);
182       if (logger!=null)
183          logger.info(msg,ex);
184       
185    }
186
187    /**
188     * Log a message object with the <i>DEBUG</i> level.
189     *
190     * @param msg the message to log.
191     *
192     */

193    public void debug (String JavaDoc msg) {
194       debug(defaultLogChannel,msg);
195    }
196
197    /**
198     * Log a message object with the <i>DEBUG</i> level.
199     *
200     * @param msg the message to log.
201     * @param ex the exception to log, including its stack trace.
202     *
203     */

204    public void debug (String JavaDoc msg,RootException ex) {
205       debug(defaultLogChannel,msg,ex);
206    }
207
208    /**
209     * Log a message object with the <i>DEBUG</i> level.
210     *
211     * @param channel the log channel to be used for logging.
212     * @param msg the message to log.
213     *
214     */

215    public void debug (String JavaDoc channel,String JavaDoc msg) {
216       Logger logger=Logger.getLogger(channel);
217       if (logger!=null)
218          logger.debug(msg);
219         
220    }
221
222    /**
223     * Log a message object with the <i>DEBUG</i> level.
224     *
225     * @param channel the log channel to be used for logging.
226     * @param msg the message to log.
227     * @param ex the exception to log, including its stack trace.
228     *
229     */

230    public void debug (String JavaDoc channel,String JavaDoc msg,RootException ex) {
231       Logger logger=Logger.getLogger(channel);
232       if (logger!=null)
233          logger.debug(msg,ex);
234       
235    }
236
237 }
238
Popular Tags