1 16 17 package org.apache.commons.logging.impl; 18 19 import org.apache.avalon.framework.logger.Logger; 20 import org.apache.commons.logging.Log; 21 22 54 public class AvalonLogger implements Log { 55 56 57 private static Logger defaultLogger = null; 58 59 private transient Logger logger = null; 60 61 66 public AvalonLogger(Logger logger) { 67 this.logger = logger; 68 } 69 70 75 public AvalonLogger(String name) { 76 if (defaultLogger == null) 77 throw new NullPointerException ("default logger has to be specified if this constructor is used!"); 78 this.logger = defaultLogger.getChildLogger(name); 79 } 80 81 85 public Logger getLogger() { 86 return logger; 87 } 88 89 95 public static void setDefaultLogger(Logger logger) { 96 defaultLogger = logger; 97 } 98 99 107 public void debug(Object message, Throwable t) { 108 if (getLogger().isDebugEnabled()) getLogger().debug(String.valueOf(message), t); 109 } 110 111 118 public void debug(Object message) { 119 if (getLogger().isDebugEnabled()) getLogger().debug(String.valueOf(message)); 120 } 121 122 130 public void error(Object message, Throwable t) { 131 if (getLogger().isErrorEnabled()) getLogger().error(String.valueOf(message), t); 132 } 133 134 141 public void error(Object message) { 142 if (getLogger().isErrorEnabled()) getLogger().error(String.valueOf(message)); 143 } 144 145 153 public void fatal(Object message, Throwable t) { 154 if (getLogger().isFatalErrorEnabled()) getLogger().fatalError(String.valueOf(message), t); 155 } 156 157 164 public void fatal(Object message) { 165 if (getLogger().isFatalErrorEnabled()) getLogger().fatalError(String.valueOf(message)); 166 } 167 168 176 public void info(Object message, Throwable t) { 177 if (getLogger().isInfoEnabled()) getLogger().info(String.valueOf(message), t); 178 } 179 180 187 public void info(Object message) { 188 if (getLogger().isInfoEnabled()) getLogger().info(String.valueOf(message)); 189 } 190 191 196 public boolean isDebugEnabled() { 197 return getLogger().isDebugEnabled(); 198 } 199 200 205 public boolean isErrorEnabled() { 206 return getLogger().isErrorEnabled(); 207 } 208 209 214 public boolean isFatalEnabled() { 215 return getLogger().isFatalErrorEnabled(); 216 } 217 218 223 public boolean isInfoEnabled() { 224 return getLogger().isInfoEnabled(); 225 } 226 227 232 public boolean isTraceEnabled() { 233 return getLogger().isDebugEnabled(); 234 } 235 236 241 public boolean isWarnEnabled() { 242 return getLogger().isWarnEnabled(); 243 } 244 245 253 public void trace(Object message, Throwable t) { 254 if (getLogger().isDebugEnabled()) getLogger().debug(String.valueOf(message), t); 255 } 256 257 264 public void trace(Object message) { 265 if (getLogger().isDebugEnabled()) getLogger().debug(String.valueOf(message)); 266 } 267 268 276 public void warn(Object message, Throwable t) { 277 if (getLogger().isWarnEnabled()) getLogger().warn(String.valueOf(message), t); 278 } 279 280 287 public void warn(Object message) { 288 if (getLogger().isWarnEnabled()) getLogger().warn(String.valueOf(message)); 289 } 290 291 } 292 | Popular Tags |