de.fesenmeyer.dbnormalizer.core.log
Class DBNormalizerLogger

java.lang.Object
  extended by de.fesenmeyer.dbnormalizer.core.log.DBNormalizerLogger

public class DBNormalizerLogger
extends Object

Application-specific logging wrapper class based on http://codeelixir.com/2006/06/19/java-logging-made-easy.aspx. Currently wraps log4j-Logging.

Author:
DF

Field Summary
private  org.apache.log4j.Logger logger
          A log4j-Logger.
private static Map loggers
          Static HashMap for all loggers.
 
Constructor Summary
private DBNormalizerLogger(Class c)
          Private Constructor for creating a logger.
 
Method Summary
 void debug(String message)
          Logs a debug message.
 void error(String message)
          Logs an error with the specified message.
 void error(String message, Throwable t)
          Logs an error message with the specified message and error.
 void fatal(String message)
          Logs a fatal error with the specified message.
 void fatal(String message, Throwable t)
          Logs a fatal error message with the specified message and error.
static DBNormalizerLogger getLogger(Class c)
          Gets the logger object for the class specified by argument c.
 void info(String message)
          Logs an info with the specified message.
 boolean isDebugLoggable()
          Returns if debug messages are loggable.
 boolean isErrorLoggable()
          Returns if error messages are loggable.
 boolean isFatalLoggable()
          Returns if fatal error messages are loggable.
 boolean isInfoLoggable()
          Returns if info messages are loggable.
 boolean isWarnLoggable()
          Returns if warn messages are loggable.
private  String mergeThrowableWithMessage(String message, Throwable t)
          This method includes information about a Throwable t in the message.
 void warn(String message)
          Logs a warning with the specified message.
 void warn(String message, Throwable t)
          Logs a warning with the specified message and error.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private org.apache.log4j.Logger logger
A log4j-Logger.


loggers

private static final Map loggers
Static HashMap for all loggers.

Constructor Detail

DBNormalizerLogger

private DBNormalizerLogger(Class c)
Private Constructor for creating a logger.

Parameters:
c -
Method Detail

getLogger

public static DBNormalizerLogger getLogger(Class c)
Gets the logger object for the class specified by argument c. Creates the logger object, if it does not yet exist.

Parameters:
c - the class
Returns:
the logger object

isFatalLoggable

public boolean isFatalLoggable()
Returns if fatal error messages are loggable.

Returns:
true, if they are loggable; false, otherwise

isErrorLoggable

public boolean isErrorLoggable()
Returns if error messages are loggable.

Returns:
true, if they are loggable; false, otherwise

isWarnLoggable

public boolean isWarnLoggable()
Returns if warn messages are loggable.

Returns:
true, if they are loggable; false, otherwise

isInfoLoggable

public boolean isInfoLoggable()
Returns if info messages are loggable.

Returns:
true, if they are loggable; false, otherwise

isDebugLoggable

public boolean isDebugLoggable()
Returns if debug messages are loggable.

Returns:
true, if they are loggable; false, otherwise

fatal

public void fatal(String message)
Logs a fatal error with the specified message.

Parameters:
message - the message

fatal

public void fatal(String message,
                  Throwable t)
Logs a fatal error message with the specified message and error.

Parameters:
message - the message
t - the error as a Throwable object

error

public void error(String message)
Logs an error with the specified message.

Parameters:
message - the message

error

public void error(String message,
                  Throwable t)
Logs an error message with the specified message and error.

Parameters:
message - the message
t - the error as a Throwable object

warn

public void warn(String message)
Logs a warning with the specified message.

Parameters:
message - the message

warn

public void warn(String message,
                 Throwable t)
Logs a warning with the specified message and error.

Parameters:
message - the message
t - the error as a Throwable object

info

public void info(String message)
Logs an info with the specified message.

Parameters:
message - the message

debug

public void debug(String message)
Logs a debug message.

Parameters:
message - the message

mergeThrowableWithMessage

private String mergeThrowableWithMessage(String message,
                                         Throwable t)
This method includes information about a Throwable t in the message. This method is needed because PatternLayout does not include the Throwable information and we do not want to use another more complex layout.

Parameters:
message - a message
t - a Throwable
Returns:
Returns a string including the message and information about the Throwable.