de.fuberlin.wiwiss.d2rq.helpers
Class Logger

java.lang.Object
  extended byde.fuberlin.wiwiss.d2rq.helpers.Logger
Direct Known Subclasses:
MockLogger

public class Logger
extends java.lang.Object

Logging class for handling debug information, warnings and errors. Implemented as a singleton. The motivation for this class is to limit the impact if we decide to change to some "real" logging facility like log4j or java.util.logging.

History:
08-03-2004: Initial version of this class.

Version:
V0.2
Author:
Richard Cyganiak

Field Summary
private  boolean debug
           
private static Logger instance
           
 
Constructor Summary
Logger()
           
 
Method Summary
 void debug(java.lang.String message)
          Sends a debug message.
 boolean debugEnabled()
          Check if debug output is enabled.
 void error(java.lang.String message)
          Sends an error message.
static Logger instance()
          Returns an instance of this class.
 void setDebug(boolean enabled)
          Enable or disable debug output.
static void setInstance(Logger instance)
          Sets the instance.
 void warning(java.lang.String message)
          Sends a warning message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

instance

private static Logger instance

debug

private boolean debug
Constructor Detail

Logger

public Logger()
Method Detail

instance

public static Logger instance()
Returns an instance of this class.

Returns:
a Logger

setInstance

public static void setInstance(Logger instance)
Sets the instance. Useful for testing.

Parameters:
instance -

setDebug

public void setDebug(boolean enabled)
Enable or disable debug output. If disabled, calls to debug are discarded.

Parameters:
enabled - true to enable debug output

debugEnabled

public boolean debugEnabled()
Check if debug output is enabled. Useful to avoid calling debug if the call contains arguments that are expensive.

Returns:
true if debug output is enabled.

debug

public void debug(java.lang.String message)
Sends a debug message. Debug message are discarded during normal operation. The default implementation prints the message to standard out if debug output ist enabled.

Parameters:
message -

warning

public void warning(java.lang.String message)
Sends a warning message. Warning messages are displayed to the user during normal operation. The default implementation prints the message to standard error.

Parameters:
message -

error

public void error(java.lang.String message)
Sends an error message. Error messages are fatal and will cancel program execution during normal operation. The default implementation is to throw a D2RQException which can be caught.

Parameters:
message -