KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.enhydra.shark.logging;
2
3 import org.apache.log4j.Logger;
4 import org.apache.log4j.PropertyConfigurator;
5 import org.enhydra.shark.api.internal.logging.LoggingManager;
6 import org.enhydra.shark.api.RootException;
7 import org.enhydra.shark.api.internal.working.CallbackUtilities;
8
9 /**
10  * Implementation of LoggingManager interface.
11  *
12  * @author Sasa Bojanic
13  * @author Tanja Jovanovic
14  */

15 public class StandardLoggingManager implements LoggingManager {
16    
17    private static final String JavaDoc defaultLogChannel="Shark";
18    private CallbackUtilities cus;
19
20    /**
21     * Configures StandardLoggingManager.
22     *
23     * @param cus an instance of CallbackUtilities used to get
24     * properties for configuring logging in Shark.
25     *
26     * @exception RootException thrown if configuring doesn't succeed.
27     */

28    public void configure (CallbackUtilities cus) throws RootException {
29       this.cus=cus;
30       PropertyConfigurator.configure(cus.getProperties());
31    }
32
33    //////////////////////////////////////////////////////////////////
34
// LoggingManager API implementation
35
//////////////////////////////////////////////////////////////////
36

37    /**
38     * Log a message object with the <i>ERROR</i> Level.
39     *
40     * @param msg the message to log.
41     *
42     * @exception RootException If something unexpected happens.
43     *
44     */

45    public void error (String JavaDoc msg) throws RootException {
46       error(defaultLogChannel,msg);
47    }
48
49    /**
50     * Log a message object with the <i>ERROR</i> Level.
51     *
52     * @param msg the message to log.
53     * @param ex the exception to log, including its stack trace.
54     *
55     * @exception RootException If something unexpected happens.
56     *
57     */

58    public void error (String JavaDoc msg,RootException ex) throws RootException {
59       error(defaultLogChannel,msg,ex);
60    }
61
62    /**
63     * Log a message object with the <i>ERROR</i> Level.
64     *
65     * @param channel the log channel to be used for logging.
66     * @param msg the message to log.
67     *
68     * @exception RootException If something unexpected happens.
69     *
70     */

71    public void error (String JavaDoc channel,String JavaDoc msg) throws RootException {
72       Logger logger=Logger.getLogger(channel);
73       if (logger!=null)
74          logger.error(msg);
75       else
76          throw new RootException("Logger does not exist!");
77          
78    }
79
80    /**
81     * Log a message object with the <i>ERROR</i> Level.
82     *
83     * @param channel the log channel to be used for logging.
84     * @param msg the message to log.
85     * @param ex the exception to log, including its stack trace.
86     *
87     * @exception RootException If something unexpected happens.
88     *
89     */

90    public void error (String JavaDoc channel,String JavaDoc msg,RootException ex) throws RootException{
91       Logger logger=Logger.getLogger(channel);
92       if (logger!=null)
93          logger.error(msg,ex);
94       else
95          throw new RootException("Logger does not exist!");
96    }
97
98    /**
99     * Log a message object with the <i>WARN</i> Level.
100     *
101     * @param msg the message to log.
102     *
103     * @exception RootException If something unexpected happens.
104     *
105     */

106    public void warn (String JavaDoc msg) throws RootException {
107       warn(defaultLogChannel,msg);
108    }
109
110    /**
111     * Log a message object with the <i>WARN</i> Level.
112     *
113     * @param msg the message to log.
114     * @param ex the exception to log, including its stack trace.
115     *
116     * @exception RootException If something unexpected happens.
117     *
118     */

119    public void warn (String JavaDoc msg,RootException ex) throws RootException {
120       warn(defaultLogChannel,msg,ex);
121    }
122
123    /**
124     * Log a message object with the <i>WARN</i> Level.
125     *
126     * @param channel the log channel to be used for logging.
127     * @param msg the message to log.
128     *
129     * @exception RootException If something unexpected happens.
130     *
131     */

132    public void warn (String JavaDoc channel,String JavaDoc msg) throws RootException {
133       Logger logger=Logger.getLogger(channel);
134       if (logger!=null)
135          logger.warn(msg);
136       else
137          throw new RootException("Logger does not exist!");
138    }
139
140    /**
141     * Log a message object with the <i>WARN</i> Level.
142     *
143     * @param channel the log channel to be used for logging.
144     * @param msg the message to log.
145     * @param ex the exception to log, including its stack trace.
146     *
147     * @exception RootException If something unexpected happens.
148     *
149     */

150    public void warn (String JavaDoc channel,String JavaDoc msg,RootException ex) throws RootException {
151       Logger logger=Logger.getLogger(channel);
152       if (logger!=null)
153          logger.warn(msg,ex);
154       else
155          throw new RootException("Logger does not exist!");
156    }
157
158    /**
159     * Log a message object with the <i>INFO</i> Level.
160     *
161     * @param msg the message to log.
162     *
163     * @exception RootException If something unexpected happens.
164     *
165     */

166    public void info (String JavaDoc msg) throws RootException {
167       info(defaultLogChannel,msg);
168    }
169
170    /**
171     * Log a message object with the <i>INFO</i> Level.
172     *
173     * @param msg the message to log.
174     * @param ex the exception to log, including its stack trace.
175     *
176     * @exception RootException If something unexpected happens.
177     *
178     */

179    public void info (String JavaDoc msg,RootException ex) throws RootException {
180       info(defaultLogChannel,msg,ex);
181    }
182
183    /**
184     * Log a message object with the <i>INFO</i> Level.
185     *
186     * @param channel the log channel to be used for logging.
187     * @param msg the message to log.
188     *
189     * @exception RootException If something unexpected happens.
190     *
191     */

192    public void info (String JavaDoc channel,String JavaDoc msg) throws RootException {
193       Logger logger=Logger.getLogger(channel);
194       if (logger!=null)
195          logger.info(msg);
196       else
197          throw new RootException("Logger does not exist!");
198    }
199
200    /**
201     * Log a message object with the <i>INFO</i> Level.
202     *
203     * @param channel the log channel to be used for logging.
204     * @param msg the message to log.
205     * @param ex the exception to log, including its stack trace.
206     *
207     * @exception RootException If something unexpected happens.
208     *
209     */

210    public void info (String JavaDoc channel,String JavaDoc msg,RootException ex) throws RootException {
211       Logger logger=Logger.getLogger(channel);
212       if (logger!=null)
213          logger.info(msg,ex);
214       else
215          throw new RootException("Logger does not exist!");
216    }
217
218    /**
219     * Log a message object with the <i>DEBUG</i> level.
220     *
221     * @param msg the message to log.
222     *
223     * @exception RootException If something unexpected happens.
224     *
225     */

226    public void debug (String JavaDoc msg) throws RootException {
227       debug(defaultLogChannel,msg);
228    }
229
230    /**
231     * Log a message object with the <i>DEBUG</i> level.
232     *
233     * @param msg the message to log.
234     * @param ex the exception to log, including its stack trace.
235     *
236     * @exception RootException If something unexpected happens.
237     *
238     */

239    public void debug (String JavaDoc msg,RootException ex) throws RootException {
240       debug(defaultLogChannel,msg,ex);
241    }
242
243    /**
244     * Log a message object with the <i>DEBUG</i> level.
245     *
246     * @param channel the log channel to be used for logging.
247     * @param msg the message to log.
248     *
249     * @exception RootException If something unexpected happens.
250     *
251     */

252    public void debug (String JavaDoc channel,String JavaDoc msg) throws RootException {
253       Logger logger=Logger.getLogger(channel);
254       if (logger!=null)
255          logger.debug(msg);
256       else
257          throw new RootException("Logger does not exist!");
258    }
259
260    /**
261     * Log a message object with the <i>DEBUG</i> level.
262     *
263     * @param channel the log channel to be used for logging.
264     * @param msg the message to log.
265     * @param ex the exception to log, including its stack trace.
266     *
267     * @exception RootException If something unexpected happens.
268     *
269     */

270    public void debug (String JavaDoc channel,String JavaDoc msg,RootException ex) throws RootException {
271       Logger logger=Logger.getLogger(channel);
272       if (logger!=null)
273          logger.debug(msg,ex);
274       else
275          throw new RootException("Logger does not exist!");
276    }
277
278 }
279
Popular Tags