KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > logicalcobwebs > logging > Log


1 /*
2  * $Header: /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/logging/Log.java,v 1.2 2003/02/08 14:27:49 chr32 Exp $
3  * $Revision: 1.2 $
4  * $Date: 2003/02/08 14:27:49 $
5  *
6  * ====================================================================
7  *
8  * The Apache Software License, Version 1.1
9  *
10  * Copyright (c) 1999-2002 The Apache Software Foundation. All rights
11  * reserved.
12  *
13  * Redistribution and use in source and binary forms, with or without
14  * modification, are permitted provided that the following conditions
15  * are met:
16  *
17  * 1. Redistributions of source code must retain the above copyright
18  * notice, this list of conditions and the following disclaimer.
19  *
20  * 2. Redistributions in binary form must reproduce the above copyright
21  * notice, this list of conditions and the following disclaimer in
22  * the documentation and/or other materials provided with the
23  * distribution.
24  *
25  * 3. The end-user documentation included with the redistribution, if
26  * any, must include the following acknowlegement:
27  * "This product includes software developed by the
28  * Apache Software Foundation (http://www.apache.org/)."
29  * Alternately, this acknowlegement may appear in the software itself,
30  * if and wherever such third-party acknowlegements normally appear.
31  *
32  * 4. The names "The Jakarta Project", "Commons", and "Apache Software
33  * Foundation" must not be used to endorse or promote products derived
34  * from this software without prior written permission. For written
35  * permission, please contact apache@apache.org.
36  *
37  * 5. Products derived from this software may not be called "Apache"
38  * nor may "Apache" appear in their names without prior written
39  * permission of the Apache Group.
40  *
41  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
42  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
43  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
44  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
45  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
46  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
47  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
48  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
49  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
50  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
51  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
52  * SUCH DAMAGE.
53  * ====================================================================
54  *
55  * This software consists of voluntary contributions made by many
56  * individuals on behalf of the Apache Software Foundation. For more
57  * information on the Apache Software Foundation, please see
58  * <http://www.apache.org/>.
59  *
60  */

61
62 package org.logicalcobwebs.logging;
63
64 /**
65  * <p>A simple logging interface abstracting logging APIs. In order to be
66  * instantiated successfully by {@link org.logicalcobwebs.logging.LogSource}, classes that implement
67  * this interface must have a constructor that takes a single String
68  * parameter representing the "name" of this Log.</p>
69  *
70  * <p> The six logging levels used by <code>Log</code> are (in order):
71  * <ol>
72  * <li>trace (the least serious)</li>
73  * <li>debug</li>
74  * <li>info</li>
75  * <li>warn</li>
76  * <li>error</li>
77  * <li>fatal (the most serious)</li>
78  * </ol>
79  * The mapping of these log levels to the concepts used by the underlying
80  * logging system is implementation dependent.
81  * The implemention should ensure, though, that this ordering behaves
82  * as expected.</p>
83  *
84  * <p>Performance is often a logging concern.
85  * By examining the appropriate property,
86  * a component can avoid expensive operations (producing information
87  * to be logged).</p>
88  *
89  * <p> For example,
90  * <code><pre>
91  * if (log.isDebugEnabled()) {
92  * ... do something expensive ...
93  * log.debug(theResult);
94  * }
95  * </pre></code>
96  * </p>
97  *
98  * <p>Configuration of the underlying logging system will generally be done
99  * external to the Logging APIs, through whatever mechanism is supported by
100  * that system.</p>
101  *
102  * @author <a HREF="mailto:sanders@apache.org">Scott Sanders</a>
103  * @author Rod Waldhoff
104  * @version $Id: Log.java,v 1.2 2003/02/08 14:27:49 chr32 Exp $
105  */

106 public interface Log {
107
108     // ----------------------------------------------------- Logging Properties
109

110
111     /**
112      * <p> Is debug logging currently enabled? </p>
113      *
114      * <p> Call this method to prevent having to perform expensive operations
115      * (for example, <code>String</code> concatination)
116      * when the log level is more than debug. </p>
117      */

118     boolean isDebugEnabled ();
119
120     /**
121      * <p> Is error logging currently enabled? </p>
122      *
123      * <p> Call this method to prevent having to perform expensive operations
124      * (for example, <code>String</code> concatination)
125      * when the log level is more than error. </p>
126      */

127     boolean isErrorEnabled ();
128
129     /**
130      * <p> Is fatal logging currently enabled? </p>
131      *
132      * <p> Call this method to prevent having to perform expensive operations
133      * (for example, <code>String</code> concatination)
134      * when the log level is more than fatal. </p>
135      */

136     boolean isFatalEnabled ();
137
138     /**
139      * <p> Is info logging currently enabled? </p>
140      *
141      * <p> Call this method to prevent having to perform expensive operations
142      * (for example, <code>String</code> concatination)
143      * when the log level is more than info. </p>
144      */

145     boolean isInfoEnabled ();
146
147     /**
148      * <p> Is trace logging currently enabled? </p>
149      *
150      * <p> Call this method to prevent having to perform expensive operations
151      * (for example, <code>String</code> concatination)
152      * when the log level is more than trace. </p>
153      */

154     boolean isTraceEnabled ();
155
156     /**
157      * <p> Is warning logging currently enabled? </p>
158      *
159      * <p> Call this method to prevent having to perform expensive operations
160      * (for example, <code>String</code> concatination)
161      * when the log level is more than warning. </p>
162      */

163     boolean isWarnEnabled ();
164
165
166     // -------------------------------------------------------- Logging Methods
167

168
169     /**
170      * <p> Log a message with trace log level. </p>
171      *
172      * @param message log this message
173      */

174     void trace (Object JavaDoc message);
175
176     /**
177      * <p> Log an error with trace log level. </p>
178      *
179      * @param message log this message
180      * @param t log this cause
181      */

182     void trace (Object JavaDoc message, Throwable JavaDoc t);
183
184     /**
185      * <p> Log a message with debug log level. </p>
186      *
187      * @param message log this message
188      */

189     void debug (Object JavaDoc message);
190
191     /**
192      * <p> Log an error with debug log level. </p>
193      *
194      * @param message log this message
195      * @param t log this cause
196      */

197     void debug (Object JavaDoc message, Throwable JavaDoc t);
198
199     /**
200      * <p> Log a message with info log level. </p>
201      *
202      * @param message log this message
203      */

204     void info (Object JavaDoc message);
205
206     /**
207      * <p> Log an error with info log level. </p>
208      *
209      * @param message log this message
210      * @param t log this cause
211      */

212     void info (Object JavaDoc message, Throwable JavaDoc t);
213
214     /**
215      * <p> Log a message with warn log level. </p>
216      *
217      * @param message log this message
218      */

219     void warn (Object JavaDoc message);
220
221     /**
222      * <p> Log an error with warn log level. </p>
223      *
224      * @param message log this message
225      * @param t log this cause
226      */

227     void warn (Object JavaDoc message, Throwable JavaDoc t);
228
229     /**
230      * <p> Log a message with error log level. </p>
231      *
232      * @param message log this message
233      */

234     void error (Object JavaDoc message);
235
236     /**
237      * <p> Log an error with error log level. </p>
238      *
239      * @param message log this message
240      * @param t log this cause
241      */

242     void error (Object JavaDoc message, Throwable JavaDoc t);
243
244     /**
245      * <p> Log a message with fatal log level. </p>
246      *
247      * @param message log this message
248      */

249     void fatal (Object JavaDoc message);
250
251     /**
252      * <p> Log an error with fatal log level. </p>
253      *
254      * @param message log this message
255      * @param t log this cause
256      */

257     void fatal (Object JavaDoc message, Throwable JavaDoc t);
258
259 }
260
261
Popular Tags