use commons-logging
[lwes-java.git] / src / main / java / org / lwes / util / Log.java
blob55ede78e0a3284eedf9d0542fd3f4d063d00e8f9
1 package org.lwes.util;
3 import org.apache.commons.logging.LogFactory;
5 /**
6 * This is a wrapper class for logging. Instead of embedding log4j or JDK logging
7 * statements in the code, we have a wrapper around JDK logging so this could be changed
8 * easily in the future. Also, since we prefer the distribution to be simple and
9 * standalone, we aren't using Commons Logging so that we don't have to bundle that in
10 * the distribution. JDK logging could easily be redirected to the destination of the
11 * library user's choice.
13 * @author Michael P. Lum
15 public class Log {
16 private static org.apache.commons.logging.Log logger = LogFactory.getLog(Log.class);
18 /**
19 * Check if debug logging is turned on. This should *always* be called
20 * before calling Log.debug.
22 * @return true if debug logging is on.
24 public static boolean isLogDebug() {
25 return logger.isDebugEnabled();
28 /**
29 * Check if trace logging is turned on. This should *always* be called
30 * before calling Log.trace.
32 * @return true if trace logging is on.
34 public static boolean isLogTrace() {
35 return logger.isTraceEnabled();
38 /**
39 * Check if info logging is turned on. This should *always* be called
40 * before calling Log.info.
42 * @return true if info logging is on.
44 public static boolean isLogInfo() {
45 return logger.isInfoEnabled();
48 /**
49 * Log a trace level message
50 * @param message the message to be logged
52 public static void trace(String message) {
53 logger.trace(message);
56 /**
57 * Log a debug level message
58 * @param message the message to be logged
60 public static void debug(String message) {
61 logger.debug(message);
64 /**
65 * Log a info level message
66 * @param message the message to be logged
68 public static void info(String message) {
69 logger.info(message);
72 /**
73 * Log a warning level message
74 * @param message the message to be logged
76 public static void warning(String message) {
77 logger.warn(message);
80 /**
81 * Log an warning level message, with associated Throwable information
82 * @param message the message to be logged
83 * @param t the Throwable associated with the log message
85 public static void warning(String message, Throwable t) {
86 logger.warn(message, t);
90 /**
91 * Log an error level message
92 * @param message the message to be logged
94 public static void error(String message) {
95 logger.error(message);
98 /**
99 * Log an error level message, with associated Throwable information
100 * @param message the message to be logged
101 * @param t the Throwable associated with the log message
103 public static void error(String message, Throwable t) {
104 logger.error(message, t);