|
| 1 | +/* |
| 2 | + * Copyright 2001-2004 The Apache Software Foundation. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package org.apache.commons.logging; |
| 18 | + |
| 19 | +/** |
| 20 | + * <p> |
| 21 | + * 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. |
| 25 | + * </p> |
| 26 | + * <p> |
| 27 | + * The six logging levels used by <code>Log</code> are (in order): |
| 28 | + * <ol> |
| 29 | + * <li>trace (the least serious)</li> |
| 30 | + * <li>debug</li> |
| 31 | + * <li>info</li> |
| 32 | + * <li>warn</li> |
| 33 | + * <li>error</li> |
| 34 | + * <li>fatal (the most serious)</li> |
| 35 | + * </ol> |
| 36 | + * The mapping of these log levels to the concepts used by the underlying |
| 37 | + * logging system is implementation dependent. |
| 38 | + * The implementation should ensure, though, that this ordering behaves |
| 39 | + * as expected. |
| 40 | + * </p> |
| 41 | + * <p> |
| 42 | + * Performance is often a logging concern. |
| 43 | + * By examining the appropriate property, |
| 44 | + * a component can avoid expensive operations (producing information |
| 45 | + * to be logged). |
| 46 | + * </p> |
| 47 | + * <p> |
| 48 | + * For example, |
| 49 | + * <code><pre> |
| 50 | + * if (log.isDebugEnabled()) { |
| 51 | + * ... do something expensive ... |
| 52 | + * log.debug(theResult); |
| 53 | + * } |
| 54 | + * </pre></code> |
| 55 | + * </p> |
| 56 | + * <p> |
| 57 | + * Configuration of the underlying logging system will generally be done |
| 58 | + * external to the Logging APIs, through whatever mechanism is supported by |
| 59 | + * that system. |
| 60 | + * </p> |
| 61 | + * <p style="color: #E40; font-weight: bold;"> |
| 62 | + * Please note that this interface is identical to that found in JCL 1.1.1. |
| 63 | + * </p> |
| 64 | + * |
| 65 | + * @author <a href="mailto:sanders@apache.org">Scott Sanders</a> |
| 66 | + * @author Rod Waldhoff |
| 67 | + * @version $Id: Log.java,v 1.19 2004/06/06 21:16:04 rdonkin Exp $ |
| 68 | + */ |
| 69 | +public interface Log |
| 70 | +{ |
| 71 | + |
| 72 | + // ----------------------------------------------------- Logging Properties |
| 73 | + |
| 74 | + /** |
| 75 | + * <p> |
| 76 | + * Is debug logging currently enabled? |
| 77 | + * </p> |
| 78 | + * <p> |
| 79 | + * Call this method to prevent having to perform expensive operations |
| 80 | + * (for example, <code>String</code> concatenation) |
| 81 | + * when the log level is more than debug. |
| 82 | + * </p> |
| 83 | + */ |
| 84 | + public boolean isDebugEnabled(); |
| 85 | + |
| 86 | + |
| 87 | + /** |
| 88 | + * <p> |
| 89 | + * Is error logging currently enabled? |
| 90 | + * </p> |
| 91 | + * <p> |
| 92 | + * Call this method to prevent having to perform expensive operations |
| 93 | + * (for example, <code>String</code> concatenation) |
| 94 | + * when the log level is more than error. |
| 95 | + * </p> |
| 96 | + */ |
| 97 | + public boolean isErrorEnabled(); |
| 98 | + |
| 99 | + |
| 100 | + /** |
| 101 | + * <p> |
| 102 | + * Is fatal logging currently enabled? |
| 103 | + * </p> |
| 104 | + * <p> |
| 105 | + * 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 fatal. |
| 108 | + * </p> |
| 109 | + */ |
| 110 | + public boolean isFatalEnabled(); |
| 111 | + |
| 112 | + |
| 113 | + /** |
| 114 | + * <p> |
| 115 | + * Is info logging currently enabled? |
| 116 | + * </p> |
| 117 | + * <p> |
| 118 | + * Call this method to prevent having to perform expensive operations |
| 119 | + * (for example, <code>String</code> concatenation) |
| 120 | + * when the log level is more than info. |
| 121 | + * </p> |
| 122 | + * |
| 123 | + * @return true if info enabled, false otherwise |
| 124 | + */ |
| 125 | + public boolean isInfoEnabled(); |
| 126 | + |
| 127 | + |
| 128 | + /** |
| 129 | + * <p> |
| 130 | + * Is trace logging currently enabled? |
| 131 | + * </p> |
| 132 | + * <p> |
| 133 | + * Call this method to prevent having to perform expensive operations |
| 134 | + * (for example, <code>String</code> concatenation) |
| 135 | + * when the log level is more than trace. |
| 136 | + * </p> |
| 137 | + * |
| 138 | + * @return true if trace enabled, false otherwise |
| 139 | + */ |
| 140 | + public boolean isTraceEnabled(); |
| 141 | + |
| 142 | + |
| 143 | + /** |
| 144 | + * <p> |
| 145 | + * Is warn logging currently enabled? |
| 146 | + * </p> |
| 147 | + * <p> |
| 148 | + * Call this method to prevent having to perform expensive operations |
| 149 | + * (for example, <code>String</code> concatenation) |
| 150 | + * when the log level is more than warn. |
| 151 | + * </p> |
| 152 | + */ |
| 153 | + public boolean isWarnEnabled(); |
| 154 | + |
| 155 | + |
| 156 | + // -------------------------------------------------------- Logging Methods |
| 157 | + |
| 158 | + /** |
| 159 | + * <p> |
| 160 | + * Log a message with trace log level. |
| 161 | + * </p> |
| 162 | + * |
| 163 | + * @param message |
| 164 | + * log this message |
| 165 | + */ |
| 166 | + public void trace(Object message); |
| 167 | + |
| 168 | + |
| 169 | + /** |
| 170 | + * <p> |
| 171 | + * Log an error with trace log level. |
| 172 | + * </p> |
| 173 | + * |
| 174 | + * @param message |
| 175 | + * log this message |
| 176 | + * @param t |
| 177 | + * log this cause |
| 178 | + */ |
| 179 | + public void trace(Object message, Throwable t); |
| 180 | + |
| 181 | + |
| 182 | + /** |
| 183 | + * <p> |
| 184 | + * Log a message with debug log level. |
| 185 | + * </p> |
| 186 | + * |
| 187 | + * @param message |
| 188 | + * log this message |
| 189 | + */ |
| 190 | + public void debug(Object message); |
| 191 | + |
| 192 | + |
| 193 | + /** |
| 194 | + * <p> |
| 195 | + * Log an error with debug log level. |
| 196 | + * </p> |
| 197 | + * |
| 198 | + * @param message |
| 199 | + * log this message |
| 200 | + * @param t |
| 201 | + * log this cause |
| 202 | + */ |
| 203 | + public void debug(Object message, Throwable t); |
| 204 | + |
| 205 | + |
| 206 | + /** |
| 207 | + * <p> |
| 208 | + * Log a message with info log level. |
| 209 | + * </p> |
| 210 | + * |
| 211 | + * @param message |
| 212 | + * log this message |
| 213 | + */ |
| 214 | + public void info(Object message); |
| 215 | + |
| 216 | + |
| 217 | + /** |
| 218 | + * <p> |
| 219 | + * Log an error with info log level. |
| 220 | + * </p> |
| 221 | + * |
| 222 | + * @param message |
| 223 | + * log this message |
| 224 | + * @param t |
| 225 | + * log this cause |
| 226 | + */ |
| 227 | + public void info(Object message, Throwable t); |
| 228 | + |
| 229 | + |
| 230 | + /** |
| 231 | + * <p> |
| 232 | + * Log a message with warn log level. |
| 233 | + * </p> |
| 234 | + * |
| 235 | + * @param message |
| 236 | + * log this message |
| 237 | + */ |
| 238 | + public void warn(Object message); |
| 239 | + |
| 240 | + |
| 241 | + /** |
| 242 | + * <p> |
| 243 | + * Log an error with warn log level. |
| 244 | + * </p> |
| 245 | + * |
| 246 | + * @param message |
| 247 | + * log this message |
| 248 | + * @param t |
| 249 | + * log this cause |
| 250 | + */ |
| 251 | + public void warn(Object message, Throwable t); |
| 252 | + |
| 253 | + |
| 254 | + /** |
| 255 | + * <p> |
| 256 | + * Log a message with error log level. |
| 257 | + * </p> |
| 258 | + * |
| 259 | + * @param message |
| 260 | + * log this message |
| 261 | + */ |
| 262 | + public void error(Object message); |
| 263 | + |
| 264 | + |
| 265 | + /** |
| 266 | + * <p> |
| 267 | + * Log an error with error log level. |
| 268 | + * </p> |
| 269 | + * |
| 270 | + * @param message |
| 271 | + * log this message |
| 272 | + * @param t |
| 273 | + * log this cause |
| 274 | + */ |
| 275 | + public void error(Object message, Throwable t); |
| 276 | + |
| 277 | + |
| 278 | + /** |
| 279 | + * <p> |
| 280 | + * Log a message with fatal log level. |
| 281 | + * </p> |
| 282 | + * |
| 283 | + * @param message |
| 284 | + * log this message |
| 285 | + */ |
| 286 | + public void fatal(Object message); |
| 287 | + |
| 288 | + |
| 289 | + /** |
| 290 | + * <p> |
| 291 | + * Log an error with fatal log level. |
| 292 | + * </p> |
| 293 | + * |
| 294 | + * @param message |
| 295 | + * log this message |
| 296 | + * @param t |
| 297 | + * log this cause |
| 298 | + */ |
| 299 | + public void fatal(Object message, Throwable t); |
| 300 | + |
| 301 | +} |
0 commit comments