3 import java
.util
.logging
.Level
;
4 import java
.util
.logging
.Logger
;
7 * This is a wrapper class for logging. Instead of embedding log4j or JDK logging
8 * statements in the code, we have a wrapper around JDK logging so this could be changed
9 * easily in the future. Also, since we prefer the distribution to be simple and
10 * standalone, we aren't using Commons Logging so that we don't have to bundle that in
11 * the distribution. JDK logging could easily be redirected to the destination of the
12 * library user's choice.
14 * @author Michael P. Lum
17 private static Logger logger
= Logger
.getLogger("org.lwes");
20 * Check if debug logging is turned on. This should *always* be called
21 * before calling Log.debug.
23 * @return true if debug logging is on.
25 public static boolean isLogDebug() {
26 return logger
.isLoggable(Level
.FINER
);
30 * Check if trace logging is turned on. This should *always* be called
31 * before calling Log.trace.
33 * @return true if trace logging is on.
35 public static boolean isLogTrace() {
36 return logger
.isLoggable(Level
.FINEST
);
40 * Check if info logging is turned on. This should *always* be called
41 * before calling Log.info.
43 * @return true if info logging is on.
45 public static boolean isLogInfo() {
46 return logger
.isLoggable(Level
.FINE
);
50 * Log a trace level message
51 * @param message the message to be logged
53 public static void trace(String message
) {
54 logger
.log(Level
.FINEST
, message
);
58 * Log a debug level message
59 * @param message the message to be logged
61 public static void debug(String message
) {
62 logger
.log(Level
.FINER
, message
);
66 * Log a info level message
67 * @param message the message to be logged
69 public static void info(String message
) {
70 logger
.log(Level
.FINE
, message
);
74 * Log a warning level message
75 * @param message the message to be logged
77 public static void warning(String message
) {
78 logger
.log(Level
.WARNING
, message
);
82 * Log an warning level message, with associated Throwable information
83 * @param message the message to be logged
84 * @param t the Throwable associated with the log message
86 public static void warning(String message
, Throwable t
) {
87 logger
.log(Level
.WARNING
, message
, t
);
92 * Log an error level message
93 * @param message the message to be logged
95 public static void error(String message
) {
96 logger
.log(Level
.SEVERE
, message
);
100 * Log an error level message, with associated Throwable information
101 * @param message the message to be logged
102 * @param t the Throwable associated with the log message
104 public static void error(String message
, Throwable t
) {
105 logger
.log(Level
.SEVERE
, message
, t
);