KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > grlea > logBridge > LogBridge


1 package org.grlea.logBridge;
2
3 // $Id: LogBridge.java,v 1.1 2005/03/02 10:46:05 grlea Exp $
4
// Copyright (c) 2005 Graham Lea. All rights reserved.
5

6 // Licensed under the Apache License, Version 2.0 (the "License");
7
// you may not use this file except in compliance with the License.
8
// You may obtain a copy of the License at
9
//
10
// http://www.apache.org/licenses/LICENSE-2.0
11
//
12
// Unless required by applicable law or agreed to in writing, software
13
// distributed under the License is distributed on an "AS IS" BASIS,
14
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
// See the License for the specific language governing permissions and
16
// limitations under the License.
17

18 /**
19  * <p>An interface for log bridges, implementations of which provide a bridge into a specific
20  * logging API.</p>
21  *
22  * <p><code>LogBridge</code> provides for five levels of debug log messages as well entry and exit
23  * tracing messages. The order of the log levels is (from most to least important):
24  * <ul>
25  * <li>Error</li>
26  * <li>Warn</li>
27  * <li>Info</li>
28  * <li>Debug</li>
29  * <li>Verbose</li>
30  * </ul>
31  * Each of these levels should be specifically mapped to some other level, flag or target in each
32  * implementation of <code>LogBridge</code>. The documentation for an implementation should provide
33  * documentation of how the mapping is performed.
34  * </p>
35  *
36  * @author grlea
37  * @version $Revision: 1.1 $
38  */

39 public interface
40 LogBridge
41 {
42    /**
43     * <p>Indicates whether logging a message at the Error level would or might result in the
44     * underlying logging package producing output for that message. This method can be used to test
45     * whether a message will be logged before undertaking expensive collation of the contents of the
46     * message.</p>
47     *
48     * <p>Where the underlying package cannot be used to accurately or quickly determine a response,
49     * <code>true</code> is returned so as to ensure that messages that might be loged are not
50     * inadvertently skipped. For the majority of logging packages, this method will have a fast and
51     * accurate implementation.</p>
52     *
53     * @return <code>true</code> if a message logged at this level would or might be output.
54     */

55    public boolean isErrorEnabled();
56
57    /**
58     * <p>Indicates whether logging a message at the Warn level would or might result in the
59     * underlying logging package producing output for that message. This method can be used to test
60     * whether a message will be logged before undertaking expensive collation of the contents of the
61     * message.</p>
62     *
63     * <p>Where the underlying package cannot be used to accurately or quickly determine a response,
64     * <code>true</code> is returned so as to ensure that messages that might be loged are not
65     * inadvertently skipped. For the majority of logging packages, this method will have a fast and
66     * accurate implementation.</p>
67     *
68     * @return <code>true</code> if a message logged at this level would or might be output.
69     */

70    public boolean isWarnEnabled();
71
72    /**
73     * <p>Indicates whether logging a message at the Info level would or might result in the
74     * underlying logging package producing output for that message. This method can be used to test
75     * whether a message will be logged before undertaking expensive collation of the contents of the
76     * message.</p>
77     *
78     * <p>Where the underlying package cannot be used to accurately or quickly determine a response,
79     * <code>true</code> is returned so as to ensure that messages that might be loged are not
80     * inadvertently skipped. For the majority of logging packages, this method will have a fast and
81     * accurate implementation.</p>
82     *
83     * @return <code>true</code> if a message logged at this level would or might be output.
84     */

85    public boolean isInfoEnabled();
86
87    /**
88     * <p>Indicates whether logging a message at the Debug level would or might result in the
89     * underlying logging package producing output for that message. This method can be used to test
90     * whether a message will be logged before undertaking expensive collation of the contents of the
91     * message.</p>
92     *
93     * <p>Where the underlying package cannot be used to accurately or quickly determine a response,
94     * <code>true</code> is returned so as to ensure that messages that might be loged are not
95     * inadvertently skipped. For the majority of logging packages, this method will have a fast and
96     * accurate implementation.</p>
97     *
98     * @return <code>true</code> if a message logged at this level would or might be output.
99     */

100    public boolean isDebugEnabled();
101
102    /**
103     * <p>Indicates whether logging a message at the Verbose level would or might result in the
104     * underlying logging package producing output for that message. This method can be used to test
105     * whether a message will be logged before undertaking expensive collation of the contents of the
106     * message.</p>
107     *
108     * <p>Where the underlying package cannot be used to accurately or quickly determine a response,
109     * <code>true</code> is returned so as to ensure that messages that might be loged are not
110     * inadvertently skipped. For the majority of logging packages, this method will have a fast and
111     * accurate implementation.</p>
112     *
113     * @return <code>true</code> if a message logged at this level would or might be output.
114     */

115    public boolean isVerboseEnabled();
116
117    /**
118     * <p>Indicates whether logging an entry or exit message would or might result in the
119     * underlying logging package producing output for that message. This method can be used to test
120     * whether a message will be logged before undertaking expensive collation of the contents of the
121     * message.</p>
122     *
123     * <p>Where the underlying package cannot be used to accurately or quickly determine a response,
124     * <code>true</code> is returned so as to ensure that messages that might be loged are not
125     * inadvertently skipped. For the majority of logging packages, this method will have a fast and
126     * accurate implementation.</p>
127     *
128     * @return <code>true</code> if a message logged at this level would or might be output.
129     */

130    public boolean isTracingEnabled();
131
132    /**
133     * Logs a string message at the Error level.
134     *
135     * @param message the message to log.
136     */

137    public void error(String JavaDoc message);
138
139    /**
140     * Logs and object's name and value at the Error level.
141     *
142     * @param objectName the name of the object or variable whose value is being logged.
143     * @param value the value of the object or value.
144     */

145    public void error(String JavaDoc objectName, Object JavaDoc value);
146
147    /**
148     * Logs an exception (throwable) at the Error level.
149     *
150     * @param error the exception to log.
151     */

152    public void error(Throwable JavaDoc error);
153
154    /**
155     * Logs a string message at the Warn level.
156     *
157     * @param message the message to log.
158     */

159    public void warn(String JavaDoc message);
160
161    /**
162     * Logs and object's name and value at the Warn level.
163     *
164     * @param objectName the name of the object or variable whose value is being logged.
165     * @param value the value of the object or value.
166     */

167    public void warn(String JavaDoc objectName, Object JavaDoc value);
168
169    /**
170     * Logs an exception (throwable) at the Warn level.
171     *
172     * @param error the exception to log.
173     */

174    public void warn(Throwable JavaDoc error);
175
176    /**
177     * Logs a string message at the Info level.
178     *
179     * @param message the message to log.
180     */

181    public void info(String JavaDoc message);
182
183    /**
184     * Logs and object's name and value at the Info level.
185     *
186     * @param objectName the name of the object or variable whose value is being logged.
187     * @param value the value of the object or value.
188     */

189    public void info(String JavaDoc objectName, Object JavaDoc value);
190
191    /**
192     * Logs an exception (throwable) at the Info level.
193     *
194     * @param error the exception to log.
195     */

196    public void info(Throwable JavaDoc error);
197
198    /**
199     * Logs a string message at the Debug level.
200     *
201     * @param message the message to log.
202     */

203    public void debug(String JavaDoc message);
204
205    /**
206     * Logs and object's name and value at the Debug level.
207     *
208     * @param objectName the name of the object or variable whose value is being logged.
209     * @param value the value of the object or value.
210     */

211    public void debug(String JavaDoc objectName, Object JavaDoc value);
212
213    /**
214     * Logs an exception (throwable) at the Debug level.
215     *
216     * @param error the exception to log.
217     */

218    public void debug(Throwable JavaDoc error);
219
220    /**
221     * Logs a string message at the Verbose level.
222     *
223     * @param message the message to log.
224     */

225    public void verbose(String JavaDoc message);
226
227    /**
228     * Logs and object's name and value at the Verbose level.
229     *
230     * @param objectName the name of the object or variable whose value is being logged.
231     * @param value the value of the object or value.
232     */

233    public void verbose(String JavaDoc objectName, Object JavaDoc value);
234
235    /**
236     * Logs an exception (throwable) at the Verbose level.
237     *
238     * @param error the exception to log.
239     */

240    public void verbose(Throwable JavaDoc error);
241
242    /**
243     * Logs an entry to a method.
244     *
245     * @param methodName the name of the method that was or is about to be entered.
246     */

247    public void entry(String JavaDoc methodName);
248
249    /**
250     * Logs the exit of a method.
251     *
252     * @param methodName the name of the method that was or is about to be exited.
253     */

254    public void exit(String JavaDoc methodName);
255 }
256
Popular Tags