com.taursys.debug
Class SimpleLogger

java.lang.Object
  extended bycom.taursys.debug.SimpleLogger
All Implemented Interfaces:
LoggerAdapter

public class SimpleLogger
extends java.lang.Object
implements LoggerAdapter

SimpleLogger is an implementation of a LoggerAdapter that outputs log into to System.err. Its default level is WARN. This is a very simple implementation. The message passed to the various logging methods is rendered using its toString method.

Version:
1.0
Author:
Marty Phelan

Constructor Summary
SimpleLogger()
          Constructs a new SimpleLogger
SimpleLogger(int level)
          Constructs a new SimpleLogger with a given level
 
Method Summary
 void debug(java.lang.Object message)
          Writes the given DEBUG message to the log if the DEBUG logging level is enabled
 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
 void error(java.lang.Object message)
          Writes the given ERROR message to the log if the ERROR logging level is enabled
 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
 void fatal(java.lang.Object message)
          Writes the given FATAL message to the log if the FATAL logging level is enabled
 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
 int getLevel()
          Gets the logging level of this SimpleLogger
 void info(java.lang.Object message)
          Writes the given INFO message to the log if the INFO logging level is enabled
 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
 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.
 boolean isInfoEnabled()
          Indicates whether or not the INFO level is enabled for logging.
 void log(int level, java.lang.Object message)
          Writes the given level message to the log if the given logging level is enabled
 void log(int level, java.lang.Object message, java.lang.Throwable t)
          Writes the given level message and stack trace to the log if the given logging level is enabled
 void setLevel(int level)
          Sets the logging level of this SimpleLogger
 void warn(java.lang.Object message)
          Writes the given WARN message to the log if the WARN logging level is enabled
 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
 

Constructor Detail

SimpleLogger

public SimpleLogger()
Constructs a new SimpleLogger


SimpleLogger

public SimpleLogger(int level)
Constructs a new SimpleLogger with a given level

Method Detail

debug

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

Specified by:
debug in interface LoggerAdapter
Parameters:
message - is an object which contains the message to log

debug

public 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

Specified by:
debug in interface LoggerAdapter
Parameters:
message - is an object which contains the message to log
t - throwable to be rendered using printStackTrace

info

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

Specified by:
info in interface LoggerAdapter
Parameters:
message - is an object which contains the message to log

info

public 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

Specified by:
info in interface LoggerAdapter
Parameters:
message - is an object which contains the message to log
t - throwable to be rendered using printStackTrace

warn

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

Specified by:
warn in interface LoggerAdapter
Parameters:
message - is an object which contains the message to log

warn

public 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

Specified by:
warn in interface LoggerAdapter
Parameters:
message - is an object which contains the message to log
t - throwable to be rendered using printStackTrace

error

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

Specified by:
error in interface LoggerAdapter
Parameters:
message - is an object which contains the message to log

error

public 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

Specified by:
error in interface LoggerAdapter
Parameters:
message - is an object which contains the message to log
t - throwable to be rendered using printStackTrace

fatal

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

Specified by:
fatal in interface LoggerAdapter
Parameters:
message - is an object which contains the message to log

fatal

public 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

Specified by:
fatal in interface LoggerAdapter
Parameters:
message - is an object which contains the message to log
t - throwable to be rendered using printStackTrace

isDebugEnabled

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

Specified by:
isDebugEnabled in interface LoggerAdapter
Returns:
true if DEBUG level is enabled

isInfoEnabled

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

Specified by:
isInfoEnabled in interface LoggerAdapter
Returns:
true if INFO level is enabled

isEnabledFor

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

Specified by:
isEnabledFor in interface LoggerAdapter
Parameters:
level - to check if enabled
Returns:
true if given level is enabled

log

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

Specified by:
log in interface LoggerAdapter
Parameters:
level - of log message
message - is an object which contains the message to log

log

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

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

setLevel

public void setLevel(int level)
Sets the logging level of this SimpleLogger

Parameters:
level - of logging for this SimppleLogger

getLevel

public int getLevel()
Gets the logging level of this SimpleLogger

Returns:
level of logging for this SimppleLogger


Copyright © 2007 Martin T Phelan. All Rights Reserved.