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