1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.commons.logging;
19
20 /***
21 * <p>A simple logging interface abstracting logging APIs. In order to be
22 * instantiated successfully by {@link LogFactory}, classes that implement
23 * this interface must have a constructor that takes a single String
24 * parameter representing the "name" of this Log.</p>
25 *
26 * <p> The six logging levels used by <code>Log</code> are (in order):
27 * <ol>
28 * <li>trace (the least serious)</li>
29 * <li>debug</li>
30 * <li>info</li>
31 * <li>warn</li>
32 * <li>error</li>
33 * <li>fatal (the most serious)</li>
34 * </ol>
35 * The mapping of these log levels to the concepts used by the underlying
36 * logging system is implementation dependent.
37 * The implemention should ensure, though, that this ordering behaves
38 * as expected.</p>
39 *
40 * <p>Performance is often a logging concern.
41 * By examining the appropriate property,
42 * a component can avoid expensive operations (producing information
43 * to be logged).</p>
44 *
45 * <p> For example,
46 * <code><pre>
47 * if (log.isDebugEnabled()) {
48 * ... do something expensive ...
49 * log.debug(theResult);
50 * }
51 * </pre></code>
52 * </p>
53 *
54 * <p>Configuration of the underlying logging system will generally be done
55 * external to the Logging APIs, through whatever mechanism is supported by
56 * that system.</p>
57 *
58 * @author <a href="mailto:sanders@apache.org">Scott Sanders</a>
59 * @author Rod Waldhoff
60 * @version $Id: Log.java,v 1.19 2004/06/06 21:16:04 rdonkin Exp $
61 */
62 public interface Log {
63
64
65
66
67
68 /***
69 * <p> Is debug logging currently enabled? </p>
70 *
71 * <p> Call this method to prevent having to perform expensive operations
72 * (for example, <code>String</code> concatenation)
73 * when the log level is more than debug. </p>
74 */
75 public boolean isDebugEnabled();
76
77
78 /***
79 * <p> Is error logging currently enabled? </p>
80 *
81 * <p> Call this method to prevent having to perform expensive operations
82 * (for example, <code>String</code> concatenation)
83 * when the log level is more than error. </p>
84 */
85 public boolean isErrorEnabled();
86
87
88 /***
89 * <p> Is fatal logging currently enabled? </p>
90 *
91 * <p> Call this method to prevent having to perform expensive operations
92 * (for example, <code>String</code> concatenation)
93 * when the log level is more than fatal. </p>
94 */
95 public boolean isFatalEnabled();
96
97
98 /***
99 * <p> Is info logging currently enabled? </p>
100 *
101 * <p> Call this method to prevent having to perform expensive operations
102 * (for example, <code>String</code> concatenation)
103 * when the log level is more than info. </p>
104 */
105 public boolean isInfoEnabled();
106
107
108 /***
109 * <p> Is trace logging currently enabled? </p>
110 *
111 * <p> Call this method to prevent having to perform expensive operations
112 * (for example, <code>String</code> concatenation)
113 * when the log level is more than trace. </p>
114 */
115 public boolean isTraceEnabled();
116
117
118 /***
119 * <p> Is warn logging currently enabled? </p>
120 *
121 * <p> Call this method to prevent having to perform expensive operations
122 * (for example, <code>String</code> concatenation)
123 * when the log level is more than warn. </p>
124 */
125 public boolean isWarnEnabled();
126
127
128
129
130
131 /***
132 * <p> Log a message with trace log level. </p>
133 *
134 * @param message log this message
135 */
136 public void trace(Object message);
137
138
139 /***
140 * <p> Log an error with trace log level. </p>
141 *
142 * @param message log this message
143 * @param t log this cause
144 */
145 public void trace(Object message, Throwable t);
146
147
148 /***
149 * <p> Log a message with debug log level. </p>
150 *
151 * @param message log this message
152 */
153 public void debug(Object message);
154
155
156 /***
157 * <p> Log an error with debug log level. </p>
158 *
159 * @param message log this message
160 * @param t log this cause
161 */
162 public void debug(Object message, Throwable t);
163
164
165 /***
166 * <p> Log a message with info log level. </p>
167 *
168 * @param message log this message
169 */
170 public void info(Object message);
171
172
173 /***
174 * <p> Log an error with info log level. </p>
175 *
176 * @param message log this message
177 * @param t log this cause
178 */
179 public void info(Object message, Throwable t);
180
181
182 /***
183 * <p> Log a message with warn log level. </p>
184 *
185 * @param message log this message
186 */
187 public void warn(Object message);
188
189
190 /***
191 * <p> Log an error with warn log level. </p>
192 *
193 * @param message log this message
194 * @param t log this cause
195 */
196 public void warn(Object message, Throwable t);
197
198
199 /***
200 * <p> Log a message with error log level. </p>
201 *
202 * @param message log this message
203 */
204 public void error(Object message);
205
206
207 /***
208 * <p> Log an error with error log level. </p>
209 *
210 * @param message log this message
211 * @param t log this cause
212 */
213 public void error(Object message, Throwable t);
214
215
216 /***
217 * <p> Log a message with fatal log level. </p>
218 *
219 * @param message log this message
220 */
221 public void fatal(Object message);
222
223
224 /***
225 * <p> Log an error with fatal log level. </p>
226 *
227 * @param message log this message
228 * @param t log this cause
229 */
230 public void fatal(Object message, Throwable t);
231
232
233 }