001: /*
002: * Copyright 2001-2004 The Apache Software Foundation.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016:
017: package org.apache.commons.logging;
018:
019: /**
020: * <p>A simple logging interface abstracting logging APIs. In order to be
021: * instantiated successfully by {@link LogFactory}, classes that implement
022: * this interface must have a constructor that takes a single String
023: * parameter representing the "name" of this Log.</p>
024: *
025: * <p> The six logging levels used by <code>Log</code> are (in order):
026: * <ol>
027: * <li>trace (the least serious)</li>
028: * <li>debug</li>
029: * <li>info</li>
030: * <li>warn</li>
031: * <li>error</li>
032: * <li>fatal (the most serious)</li>
033: * </ol>
034: * The mapping of these log levels to the concepts used by the underlying
035: * logging system is implementation dependent.
036: * The implemention should ensure, though, that this ordering behaves
037: * as expected.</p>
038: *
039: * <p>Performance is often a logging concern.
040: * By examining the appropriate property,
041: * a component can avoid expensive operations (producing information
042: * to be logged).</p>
043: *
044: * <p> For example,
045: * <code><pre>
046: * if (log.isDebugEnabled()) {
047: * ... do something expensive ...
048: * log.debug(theResult);
049: * }
050: * </pre></code>
051: * </p>
052: *
053: * <p>Configuration of the underlying logging system will generally be done
054: * external to the Logging APIs, through whatever mechanism is supported by
055: * that system.</p>
056: *
057: * @author <a href="mailto:sanders@apache.org">Scott Sanders</a>
058: * @author Rod Waldhoff
059: * @version $Id: Log.java 381838 2006-02-28 23:57:11Z skitching $
060: */
061: public interface Log {
062:
063: // ----------------------------------------------------- Logging Properties
064:
065: /**
066: * <p> Is debug logging currently enabled? </p>
067: *
068: * <p> Call this method to prevent having to perform expensive operations
069: * (for example, <code>String</code> concatenation)
070: * when the log level is more than debug. </p>
071: *
072: * @return true if debug is enabled in the underlying logger.
073: */
074: public boolean isDebugEnabled();
075:
076: /**
077: * <p> Is error logging currently enabled? </p>
078: *
079: * <p> Call this method to prevent having to perform expensive operations
080: * (for example, <code>String</code> concatenation)
081: * when the log level is more than error. </p>
082: *
083: * @return true if error is enabled in the underlying logger.
084: */
085: public boolean isErrorEnabled();
086:
087: /**
088: * <p> Is fatal logging currently enabled? </p>
089: *
090: * <p> Call this method to prevent having to perform expensive operations
091: * (for example, <code>String</code> concatenation)
092: * when the log level is more than fatal. </p>
093: *
094: * @return true if fatal is enabled in the underlying logger.
095: */
096: public boolean isFatalEnabled();
097:
098: /**
099: * <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: * @return true if info is enabled in the underlying logger.
106: */
107: public boolean isInfoEnabled();
108:
109: /**
110: * <p> Is trace logging currently enabled? </p>
111: *
112: * <p> Call this method to prevent having to perform expensive operations
113: * (for example, <code>String</code> concatenation)
114: * when the log level is more than trace. </p>
115: *
116: * @return true if trace is enabled in the underlying logger.
117: */
118: public boolean isTraceEnabled();
119:
120: /**
121: * <p> Is warn logging currently enabled? </p>
122: *
123: * <p> Call this method to prevent having to perform expensive operations
124: * (for example, <code>String</code> concatenation)
125: * when the log level is more than warn. </p>
126: *
127: * @return true if warn is enabled in the underlying logger.
128: */
129: public boolean isWarnEnabled();
130:
131: // -------------------------------------------------------- Logging Methods
132:
133: /**
134: * <p> Log a message with trace log level. </p>
135: *
136: * @param message log this message
137: */
138: public void trace(Object message);
139:
140: /**
141: * <p> Log an error with trace log level. </p>
142: *
143: * @param message log this message
144: * @param t log this cause
145: */
146: public void trace(Object message, Throwable t);
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: * <p> Log an error with debug log level. </p>
157: *
158: * @param message log this message
159: * @param t log this cause
160: */
161: public void debug(Object message, Throwable t);
162:
163: /**
164: * <p> Log a message with info log level. </p>
165: *
166: * @param message log this message
167: */
168: public void info(Object message);
169:
170: /**
171: * <p> Log an error with info log level. </p>
172: *
173: * @param message log this message
174: * @param t log this cause
175: */
176: public void info(Object message, Throwable t);
177:
178: /**
179: * <p> Log a message with warn log level. </p>
180: *
181: * @param message log this message
182: */
183: public void warn(Object message);
184:
185: /**
186: * <p> Log an error with warn log level. </p>
187: *
188: * @param message log this message
189: * @param t log this cause
190: */
191: public void warn(Object message, Throwable t);
192:
193: /**
194: * <p> Log a message with error log level. </p>
195: *
196: * @param message log this message
197: */
198: public void error(Object message);
199:
200: /**
201: * <p> Log an error with error log level. </p>
202: *
203: * @param message log this message
204: * @param t log this cause
205: */
206: public void error(Object message, Throwable t);
207:
208: /**
209: * <p> Log a message with fatal log level. </p>
210: *
211: * @param message log this message
212: */
213: public void fatal(Object message);
214:
215: /**
216: * <p> Log an error with fatal log level. </p>
217: *
218: * @param message log this message
219: * @param t log this cause
220: */
221: public void fatal(Object message, Throwable t);
222:
223: }
|