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: * <p style="color: #E40; font-weight: bold;">Please note that this interface is identical to that found in JCL 1.0.4.</p>
058: *
059: * @author <a href="mailto:sanders@apache.org">Scott Sanders</a>
060: * @author Rod Waldhoff
061: * @version $Id: Log.java,v 1.19 2004/06/06 21:16:04 rdonkin Exp $
062: */
063: public interface Log {
064:
065: // ----------------------------------------------------- Logging Properties
066:
067: /**
068: * <p> Is debug logging currently enabled? </p>
069: *
070: * <p> Call this method to prevent having to perform expensive operations
071: * (for example, <code>String</code> concatenation)
072: * when the log level is more than debug. </p>
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: public boolean isErrorEnabled();
084:
085: /**
086: * <p> Is fatal logging currently enabled? </p>
087: *
088: * <p> Call this method to prevent having to perform expensive operations
089: * (for example, <code>String</code> concatenation)
090: * when the log level is more than fatal. </p>
091: */
092: public boolean isFatalEnabled();
093:
094: /**
095: * <p> Is info logging currently enabled? </p>
096: *
097: * <p> Call this method to prevent having to perform expensive operations
098: * (for example, <code>String</code> concatenation)
099: * when the log level is more than info. </p>
100: */
101: public boolean isInfoEnabled();
102:
103: /**
104: * <p> Is trace logging currently enabled? </p>
105: *
106: * <p> Call this method to prevent having to perform expensive operations
107: * (for example, <code>String</code> concatenation)
108: * when the log level is more than trace. </p>
109: */
110: public boolean isTraceEnabled();
111:
112: /**
113: * <p> Is warn logging currently enabled? </p>
114: *
115: * <p> Call this method to prevent having to perform expensive operations
116: * (for example, <code>String</code> concatenation)
117: * when the log level is more than warn. </p>
118: */
119: public boolean isWarnEnabled();
120:
121: // -------------------------------------------------------- Logging Methods
122:
123: /**
124: * <p> Log a message with trace log level. </p>
125: *
126: * @param message log this message
127: */
128: public void trace(Object message);
129:
130: /**
131: * <p> Log an error with trace log level. </p>
132: *
133: * @param message log this message
134: * @param t log this cause
135: */
136: public void trace(Object message, Throwable t);
137:
138: /**
139: * <p> Log a message with debug log level. </p>
140: *
141: * @param message log this message
142: */
143: public void debug(Object message);
144:
145: /**
146: * <p> Log an error with debug log level. </p>
147: *
148: * @param message log this message
149: * @param t log this cause
150: */
151: public void debug(Object message, Throwable t);
152:
153: /**
154: * <p> Log a message with info log level. </p>
155: *
156: * @param message log this message
157: */
158: public void info(Object message);
159:
160: /**
161: * <p> Log an error with info log level. </p>
162: *
163: * @param message log this message
164: * @param t log this cause
165: */
166: public void info(Object message, Throwable t);
167:
168: /**
169: * <p> Log a message with warn log level. </p>
170: *
171: * @param message log this message
172: */
173: public void warn(Object message);
174:
175: /**
176: * <p> Log an error with warn log level. </p>
177: *
178: * @param message log this message
179: * @param t log this cause
180: */
181: public void warn(Object message, Throwable t);
182:
183: /**
184: * <p> Log a message with error log level. </p>
185: *
186: * @param message log this message
187: */
188: public void error(Object message);
189:
190: /**
191: * <p> Log an error with error log level. </p>
192: *
193: * @param message log this message
194: * @param t log this cause
195: */
196: public void error(Object message, Throwable t);
197:
198: /**
199: * <p> Log a message with fatal log level. </p>
200: *
201: * @param message log this message
202: */
203: public void fatal(Object message);
204:
205: /**
206: * <p> Log an error with fatal log level. </p>
207: *
208: * @param message log this message
209: * @param t log this cause
210: */
211: public void fatal(Object message, Throwable t);
212:
213: }
|