com.taursys.debug
Class Debug

java.lang.Object
  extended bycom.taursys.debug.Debug

public class Debug
extends java.lang.Object

Debug is a singleton with static methods to log information. Debug is proxy to the actual logging class. You use Debug with any logging system by implementing a LoggerAdapter for the target system. You can then assign that loggin system to this Debug by using the setLoggerAdapter method. By default Debug will create its own SimpleLogger which outputs to the err device.

Version:
1.0
Author:
Marty Phelan
See Also:
SimpleLogger

Field Summary
static int DEBUG
          DEBUG level is highest logging level
static int ERROR
          ERROR level is fourth highest logging level
static int FATAL
          FATAL level is lowest logging level
static int INFO
          INFO level is second highest logging level
static java.lang.String[] LEVEL_NAMES
          String array of logging level names
static int WARN
          WARN level is third highest logging level
 
Method Summary
static void debug(java.lang.Object message)
          Writes the given DEBUG message to the log if the DEBUG logging level is enabled
static void debug(java.lang.Object message, java.lang.Throwable t)
          Writes the given DEBUG message and stack trace to the log if the DEBUG logging level is enabled
static void error(java.lang.Object message)
          Writes the given ERROR message to the log if the ERROR logging level is enabled
static void error(java.lang.Object message, java.lang.Throwable t)
          Writes the given ERROR message and stack trace to the log if the ERROR logging level is enabled
static void fatal(java.lang.Object message)
          Writes the given FATAL message to the log if the FATAL logging level is enabled
static void fatal(java.lang.Object message, java.lang.Throwable t)
          Writes the given FATAL message and stack trace to the log if the FATAL logging level is enabled
static Debug getInstance()
          Returns the singleton Debug instance.
static LoggerAdapter getLoggerAdapter()
          Gets the LoggerAdapter used by the singleton Debug.
static void info(java.lang.Object message)
          Writes the given INFO message to the log if the INFO logging level is enabled
static void info(java.lang.Object message, java.lang.Throwable t)
          Writes the given INFO message and stack trace to the log if the INFO logging level is enabled
static boolean isDebugEnabled()
          Indicates whether or not the DEBUG level is enabled for logging.
 boolean isEnabledFor(int level)
          Indicates whether or not the given level is enabled for logging.
static boolean isInfoEnabled()
          Indicates whether or not the INFO level is enabled for logging.
static void log(int level, java.lang.String message)
          Writes the given level message to the log if the given logging level is enabled
static void log(int level, java.lang.String message, java.lang.Throwable t)
          Writes the given level message and stack trace to the log if the given logging level is enabled
static void setLoggerAdapter(LoggerAdapter loggerAdapter)
          Sets the LoggerAdapter used by the singleton Debug.
static void warn(java.lang.Object message)
          Writes the given WARN message to the log if the WARN logging level is enabled
static void warn(java.lang.Object message, java.lang.Throwable t)
          Writes the given WARN message and stack trace to the log if the WARN logging level is enabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

public static final int DEBUG
DEBUG level is highest logging level

See Also:
Constant Field Values

INFO

public static final int INFO
INFO level is second highest logging level

See Also:
Constant Field Values

WARN

public static final int WARN
WARN level is third highest logging level

See Also:
Constant Field Values

ERROR

public static final int ERROR
ERROR level is fourth highest logging level

See Also:
Constant Field Values

FATAL

public static final int FATAL
FATAL level is lowest logging level

See Also:
Constant Field Values

LEVEL_NAMES

public static final java.lang.String[] LEVEL_NAMES
String array of logging level names

Method Detail

getInstance

public static Debug getInstance()
Returns the singleton Debug instance.

Returns:
singleton Debug instance.

setLoggerAdapter

public static void setLoggerAdapter(LoggerAdapter loggerAdapter)
Sets the LoggerAdapter used by the singleton Debug.

Parameters:
loggerAdapter - to by used by the singleton Debug.

getLoggerAdapter

public static LoggerAdapter getLoggerAdapter()
Gets the LoggerAdapter used by the singleton Debug.

Returns:
loggerAdapter to by used by the singleton Debug.

debug

public static void debug(java.lang.Object message)
Writes the given DEBUG message to the log if the DEBUG logging level is enabled

Parameters:
message - is an object which contains the message to log

debug

public static void debug(java.lang.Object message,
                         java.lang.Throwable t)
Writes the given DEBUG message and stack trace to the log if the DEBUG logging level is enabled

Parameters:
message - is an object which contains the message to log
t - throwable to be rendered using printStackTrace

info

public static void info(java.lang.Object message)
Writes the given INFO message to the log if the INFO logging level is enabled

Parameters:
message - is an object which contains the message to log

info

public static void info(java.lang.Object message,
                        java.lang.Throwable t)
Writes the given INFO message and stack trace to the log if the INFO logging level is enabled

Parameters:
message - is an object which contains the message to log
t - throwable to be rendered using printStackTrace

warn

public static void warn(java.lang.Object message)
Writes the given WARN message to the log if the WARN logging level is enabled

Parameters:
message - is an object which contains the message to log

warn

public static void warn(java.lang.Object message,
                        java.lang.Throwable t)
Writes the given WARN message and stack trace to the log if the WARN logging level is enabled

Parameters:
message - is an object which contains the message to log
t - throwable to be rendered using printStackTrace

error

public static void error(java.lang.Object message)
Writes the given ERROR message to the log if the ERROR logging level is enabled

Parameters:
message - is an object which contains the message to log

error

public static void error(java.lang.Object message,
                         java.lang.Throwable t)
Writes the given ERROR message and stack trace to the log if the ERROR logging level is enabled

Parameters:
message - is an object which contains the message to log
t - throwable to be rendered using printStackTrace

fatal

public static void fatal(java.lang.Object message)
Writes the given FATAL message to the log if the FATAL logging level is enabled

Parameters:
message - is an object which contains the message to log

fatal

public static void fatal(java.lang.Object message,
                         java.lang.Throwable t)
Writes the given FATAL message and stack trace to the log if the FATAL logging level is enabled

Parameters:
message - is an object which contains the message to log
t - throwable to be rendered using printStackTrace

isDebugEnabled

public static boolean isDebugEnabled()
Indicates whether or not the DEBUG level is enabled for logging.

Returns:
true if DEBUG level is enabled

isInfoEnabled

public static boolean isInfoEnabled()
Indicates whether or not the INFO level is enabled for logging.

Returns:
true if INFO level is enabled

isEnabledFor

public boolean isEnabledFor(int level)
Indicates whether or not the given level is enabled for logging.

Parameters:
level - to check if enabled
Returns:
true if given level is enabled

log

public static void log(int level,
                       java.lang.String message)
Writes the given level message to the log if the given logging level is enabled

Parameters:
level - of log message
message - is an object which contains the message to log

log

public static void log(int level,
                       java.lang.String message,
                       java.lang.Throwable t)
Writes the given level message and stack trace to the log if the given logging level is enabled

Parameters:
level - of log message
message - is an object which contains the message to log
t - throwable to be rendered using printStackTrace


Copyright © 2007 Martin T Phelan. All Rights Reserved.