org.aspsimon.cdlib.core
Class LogUtils

java.lang.Object
  extended by org.aspsimon.cdlib.core.LogUtils

public class LogUtils
extends java.lang.Object

LogUtils is a utility class for logging functionality. CDLib's logging is controlled by binary switches, meaning that the basic functionality of a "normal" logging class like log4j is not quite sufficient. Loglevels are set in the configuration file, which is read at startup of the application.

The loglevels are defined as follows:

This means that to activate all logging to the console, the user could set the cdlib.loglevel property to 63 (32+16+8+4+2+1). To log everything to the logfile, set it to 31. To only log network traffic and warning messages, but not exception stacktraces, informational messages or function entry and exit points, the value would be set to 2+8 = 10.

Version:
$Revision: 1.1 $
Author:
Simon Bailey

Method Summary
 void closeLog()
          close the log file gracefully.
 boolean evaluateLogging(int checkLevel)
          Check if logging for the given level is activated.
static LogUtils getInstance()
           
 void logError(java.lang.Exception e)
          Log stack trace to the logfile
 void logError(java.lang.Exception e, java.lang.String msg)
          Log a message and the stack trace to the logfile
 void logFunction(java.lang.String msg, boolean entry)
          Log function entry and exit points.
 void logInfo(java.lang.String msg)
          Log informational messages
 void logNetwork(java.lang.String msg, boolean outgoing)
          Log network traffic sent in and out
 void logWarn(java.lang.String msg)
          Log warning messages
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static LogUtils getInstance()
Returns:
the instance of this Singleton class

evaluateLogging

public boolean evaluateLogging(int checkLevel)
Check if logging for the given level is activated. I'm lazy, so sue me. :)

Parameters:
checkLevel - the loglevel to be checked.
Returns:
true if the loglevel is active, false otherwise.

logFunction

public void logFunction(java.lang.String msg,
                        boolean entry)
Log function entry and exit points.

Parameters:
msg - What to log
entry - true for entry and false for exit.

logNetwork

public void logNetwork(java.lang.String msg,
                       boolean outgoing)
Log network traffic sent in and out

Parameters:
msg - What to log
outgoing - true for outgoing traffic, false for incoming.

logInfo

public void logInfo(java.lang.String msg)
Log informational messages

Parameters:
msg - What to log

logWarn

public void logWarn(java.lang.String msg)
Log warning messages

Parameters:
msg - What to log

logError

public void logError(java.lang.Exception e)
Log stack trace to the logfile

Parameters:
e - Exception to log
See Also:
Exception

logError

public void logError(java.lang.Exception e,
                     java.lang.String msg)
Log a message and the stack trace to the logfile

Parameters:
e - Exception to log
msg - Informational message
See Also:
Exception

closeLog

public void closeLog()
close the log file gracefully. this seems to be needed so that all the information actually ends up in the log file. and tidying up is a good thing anyway. :)