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 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 (at) apache.org">Scott Sanders</a> 59 * @author Rod Waldhoff 60 * @version $Id: Log.java 381838 2006-02-28 23:57:11Z skitching $ 61 * 62 * @deprecated Please use {@link java.net.URL#openConnection} instead. 63 * Please visit <a href="http://android-developers.blogspot.com/2011/09/androids-http-clients.html">this webpage</a> 64 * for further details. 65 */ 66 @Deprecated 67 public interface Log { 68 69 70 // ----------------------------------------------------- Logging Properties 71 72 73 /** 74 * <p> Is debug logging currently enabled? </p> 75 * 76 * <p> Call this method to prevent having to perform expensive operations 77 * (for example, <code>String</code> concatenation) 78 * when the log level is more than debug. </p> 79 * 80 * @return true if debug is enabled in the underlying logger. 81 */ 82 public boolean isDebugEnabled(); 83 84 85 /** 86 * <p> Is error logging currently enabled? </p> 87 * 88 * <p> Call this method to prevent having to perform expensive operations 89 * (for example, <code>String</code> concatenation) 90 * when the log level is more than error. </p> 91 * 92 * @return true if error is enabled in the underlying logger. 93 */ 94 public boolean isErrorEnabled(); 95 96 97 /** 98 * <p> Is fatal logging currently enabled? </p> 99 * 100 * <p> Call this method to prevent having to perform expensive operations 101 * (for example, <code>String</code> concatenation) 102 * when the log level is more than fatal. </p> 103 * 104 * @return true if fatal is enabled in the underlying logger. 105 */ 106 public boolean isFatalEnabled(); 107 108 109 /** 110 * <p> Is info 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 info. </p> 115 * 116 * @return true if info is enabled in the underlying logger. 117 */ 118 public boolean isInfoEnabled(); 119 120 121 /** 122 * <p> Is trace logging currently enabled? </p> 123 * 124 * <p> Call this method to prevent having to perform expensive operations 125 * (for example, <code>String</code> concatenation) 126 * when the log level is more than trace. </p> 127 * 128 * @return true if trace is enabled in the underlying logger. 129 */ 130 public boolean isTraceEnabled(); 131 132 133 /** 134 * <p> Is warn logging currently enabled? </p> 135 * 136 * <p> Call this method to prevent having to perform expensive operations 137 * (for example, <code>String</code> concatenation) 138 * when the log level is more than warn. </p> 139 * 140 * @return true if warn is enabled in the underlying logger. 141 */ 142 public boolean isWarnEnabled(); 143 144 145 // -------------------------------------------------------- Logging Methods 146 147 148 /** 149 * <p> Log a message with trace log level. </p> 150 * 151 * @param message log this message 152 */ 153 public void trace(Object message); 154 155 156 /** 157 * <p> Log an error with trace log level. </p> 158 * 159 * @param message log this message 160 * @param t log this cause 161 */ 162 public void trace(Object message, Throwable t); 163 164 165 /** 166 * <p> Log a message with debug log level. </p> 167 * 168 * @param message log this message 169 */ 170 public void debug(Object message); 171 172 173 /** 174 * <p> Log an error with debug log level. </p> 175 * 176 * @param message log this message 177 * @param t log this cause 178 */ 179 public void debug(Object message, Throwable t); 180 181 182 /** 183 * <p> Log a message with info log level. </p> 184 * 185 * @param message log this message 186 */ 187 public void info(Object message); 188 189 190 /** 191 * <p> Log an error with info log level. </p> 192 * 193 * @param message log this message 194 * @param t log this cause 195 */ 196 public void info(Object message, Throwable t); 197 198 199 /** 200 * <p> Log a message with warn log level. </p> 201 * 202 * @param message log this message 203 */ 204 public void warn(Object message); 205 206 207 /** 208 * <p> Log an error with warn log level. </p> 209 * 210 * @param message log this message 211 * @param t log this cause 212 */ 213 public void warn(Object message, Throwable t); 214 215 216 /** 217 * <p> Log a message with error log level. </p> 218 * 219 * @param message log this message 220 */ 221 public void error(Object message); 222 223 224 /** 225 * <p> Log an error with error log level. </p> 226 * 227 * @param message log this message 228 * @param t log this cause 229 */ 230 public void error(Object message, Throwable t); 231 232 233 /** 234 * <p> Log a message with fatal log level. </p> 235 * 236 * @param message log this message 237 */ 238 public void fatal(Object message); 239 240 241 /** 242 * <p> Log an error with fatal log level. </p> 243 * 244 * @param message log this message 245 * @param t log this cause 246 */ 247 public void fatal(Object message, Throwable t); 248 249 250 } 251