KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > slide > util > logger > Logger


1 /*
2  * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/util/logger/Logger.java,v 1.9 2004/07/28 09:34:23 ib Exp $
3  * $Revision: 1.9 $
4  * $Date: 2004/07/28 09:34:23 $
5  *
6  * ====================================================================
7  *
8  * Copyright 1999-2002 The Apache Software Foundation
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  */

23
24 package org.apache.slide.util.logger;
25
26 /**
27  * The <code>Logger</code> block interface.
28  * <p />
29  * This interface must be implemented by those blocks willing to log data
30  * coming from other blocks.
31  * <p />
32  * The six levels used for logging are (in order of gravity): EMERGENCY,
33  * CRITICAL, ERROR, WARNING, INFO and DEBUG.
34  *
35  * @version 1.0 (CVS $Revision: 1.9 $ $Date: 2004/07/28 09:34:23 $)
36  */

37 public interface Logger {
38     
39     
40     // -------------------------------------------------------------- Constants
41

42     
43     /**
44      * The EMERGENCY logging level (anything logged under this level means
45      * that a <b>critical permanent error</b> was detected).
46      * <p />
47      * When a <code>Block</code> logs something with this level means that
48      * any other task will be impossible without administrator's intervention.
49      * <p />
50      * Example:
51      * <ul>
52      * <li><i>
53      * AJP handler cannot find the secret key file. Cannot process servlet
54      * requests.
55      * </i></li>
56      * <li><i>
57      * Cannot access to mail server database URL jdbc:mysql://localhost/users
58      * (SQLException caught in driver initialization)
59      * </i></li>
60      * </ul>
61      */

62     public static final int EMERGENCY=0;
63     
64     
65     /**
66      * The CRITICAL logging level (anything logged under this level means that
67      * a <b>critical temporary error</b> was detected).
68      * <p />
69      * When a <code>Block</code> logs something with this level means that
70      * tasks similar to the one generating the error will be impossible
71      * without administrator's intervention, but other tasks (maybe using
72      * different resources) will be possible.
73      * <p />
74      * Example:
75      * <ul>
76      * <li><i>
77      * Cannot serve servlet in zone &quot;myServletZone&quot; (repository not
78      * found)
79      * </i></li>
80      * <li><i>
81      * Cannot alias address &quot;listserv@apache.org&quot; to ListServlet
82      * (mail servlet not found)
83      * </i></li>
84      * </ul>
85      */

86     public static final int CRITICAL=1;
87     
88     
89     /**
90      * The ERROR logging level (anything logged under this level means that a
91      * <b>non-critical error</b> was detected).
92      * <p />
93      * When a <code>Block</code> logs something with this level means that
94      * the current tasks failed to execute, but the stability of the block is
95      * not compromised.
96      * <p />
97      * Example:
98      * <ul>
99      * <li><i>
100      * Cannot serve servlet &quot;SnoopServlet&quot; to client 192.168.1.1 due
101      * to security restriction
102      * </i></li>
103      * <li><i>
104      * User &quot;ianosh&quot; denied access via POP3 protocol due to invalid
105      * password
106      * </i></li>
107      * </ul>
108      */

109     public static final int ERROR=2;
110
111     /**
112      * The WARNING logging level (anything logged under this level means that
113      * a <b>generic error</b> was detected).
114      * <p />
115      * When a <code>Block</code> logs something with this level means that
116      * the current tasks failed to execute due to inconsistencies in the
117      * request handled by the block.
118      * <p />
119      * Example:
120      * <ul>
121      * <li><i>
122      * Cannot find servlet &quot;SnoopServlet&quot; requested by 192.168.1.1
123      * via AJP protocol
124      * </i></li>
125      * <li><i>
126      * Cannot deliver mail from &quot;root@localhost&quot; to
127      * &quot;ianosh@iname.com&quot; via protocol SMTP (user not found)
128      * </i></li>
129      * </ul>
130      */

131     public static final int WARNING=4;
132     
133     
134     /**
135      * The INFO logging level (anything logged under this level means that
136      * an <b>informative message</b> must be logged).
137      * <p />
138      * When a <code>Block</code> logs something with this level means that
139      * something that may be interesting happened.
140      * <p />
141      * Example:
142      * <ul>
143      * <li><i>
144      * Successfully handled request from 192.168.1.1 via AJP protocol for
145      * &quot;SnoopServlet&quot; servlet
146      * </i></li>
147      * <li><i>
148      * Mail from &quot;root@localhost&quot; delivered successfully to
149      * &quot;ianosh@iname.com&quot; via protocol SMTP
150      * </i></li>
151      * </ul>
152      */

153     public static final int INFO=6;
154     
155     
156     /**
157      * The DEBUG logging level (anything logged under this level means that
158      * an <b>debug message</b> must be logged).
159      * <p />
160      * When a <code>Block</code> logs something with this level means that
161      * something that may be interesting while developing, tracking bugs or
162      * misconfigurations.
163      * <p />
164      * <p />
165      * Example:
166      * <ul>
167      * <li><i>
168      * Requested servlet &quot;snoop&quot; was aliased to
169      * &quot;org.apache.servlets.SnoopServlet&quot;
170      * </i></li>
171      * <li><i>
172      * MX record for domain &quot;dom.tld&quot; resolved to host
173      * &quot;mail.dom.tld&quot; (192.168.1.1) with preference level 10
174      * </i></li>
175      * </ul>
176      */

177     public static final int DEBUG=7;
178     
179     
180     /**
181      * Specify the default string for logging without a channel.
182      */

183     public static String JavaDoc DEFAULT_CHANNEL = "org.apache.slide.util.logger";
184     
185     
186     // ------------------------------------------------------ Interface Methods
187

188     
189     /**
190      * Log an object and an associated throwable thru the specified channel and with the specified level.
191      *
192      * @param data object to log
193      * @param throwable throwable to be logged
194      * @param channel channel name used for logging
195      * @param level level used for logging
196      */

197     public void log(Object JavaDoc data, Throwable JavaDoc throwable, String JavaDoc channel, int level);
198
199     
200     /**
201      * Log an object thru the specified channel and with the specified level.
202      *
203      * @param data The object to log.
204      * @param channel The channel name used for logging.
205      * @param level The level used for logging.
206      */

207     public void log(Object JavaDoc data, String JavaDoc channel, int level);
208     
209     
210     /**
211      * Log an object with the specified level.
212      *
213      * @param data The object to log.
214      * @param level The level used for logging.
215      */

216     public void log(Object JavaDoc data, int level);
217     
218     
219     /**
220      * Log an object.
221      *
222      * @param data The object to log.
223      */

224     public void log(Object JavaDoc data);
225     
226         
227     
228     /**
229      * Set the logger level for the default channel
230      *
231      * @param level The new log level
232      */

233
234     public void setLoggerLevel(int level);
235     
236     
237             
238     /**
239      * Set the logger level for the specified channel
240      *
241      * @param channel The channel for which the level is set.
242      * @param level The new log level
243      */

244
245     public void setLoggerLevel(String JavaDoc channel, int level);
246     
247         
248     
249     /**
250      * Get the logger level for the default channel
251      */

252
253     public int getLoggerLevel();
254     
255     
256             
257     /**
258      * Get the logger level for the specified channel
259      *
260      * @param channel The channel whose log level is returned.
261      */

262
263     public int getLoggerLevel(String JavaDoc channel);
264             
265     
266         
267     
268     /**
269      * Check if the channel with the specified level is enabled for logging.
270      *
271      * @param channel The channel specification
272      * @param level The level specification
273      */

274
275     public boolean isEnabled(String JavaDoc channel, int level);
276             
277         
278     
279     /**
280      * Check if the default channel with the specified level is enabled for logging.
281      *
282      * @param level The level specification
283      */

284
285     public boolean isEnabled(int level);
286             
287 }
288
Popular Tags