Package com.mckoi.debug
Class DefaultDebugLogger
- java.lang.Object
-
- com.mckoi.debug.DefaultDebugLogger
-
- All Implemented Interfaces:
DebugLogger
,Lvl
public class DefaultDebugLogger extends java.lang.Object implements DebugLogger
A default implementation of DebugLogger that logs messages to a PrintWriter object.This implementation allows for filtering of log messages of particular depth. So for example, only message above or equal to level ALERT are shown.
- Author:
- Tobias Downer
-
-
Constructor Summary
Constructors Constructor Description DefaultDebugLogger()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
isInterestedIn(int level)
Queries the current debug level.void
listenToEventDispatcher()
Sets up the system so that the debug messenger will intercept event dispatch errors and output the event to the debug stream.void
setDebugLevel(int level)
Sets the debug level that's to be output to the stream.void
setOutput(java.io.Writer out)
Sets up the OutputStream to which the debug information is to be output to.void
write(int level, java.lang.Class cla, java.lang.String message)
void
write(int level, java.lang.Object ob, java.lang.String message)
This writes the given debugging string.void
write(int level, java.lang.String class_string, java.lang.String message)
void
writeException(int level, java.lang.Throwable e)
This writes the given Exception but gives it a 'debug_level'.void
writeException(java.lang.Throwable e)
This writes the given Exception.
-
-
-
Method Detail
-
setOutput
public final void setOutput(java.io.Writer out)
Sets up the OutputStream to which the debug information is to be output to.
-
setDebugLevel
public final void setDebugLevel(int level)
Sets the debug level that's to be output to the stream. Set to 255 to stop all output to the stream.
-
listenToEventDispatcher
public final void listenToEventDispatcher()
Sets up the system so that the debug messenger will intercept event dispatch errors and output the event to the debug stream.
-
isInterestedIn
public final boolean isInterestedIn(int level)
Description copied from interface:DebugLogger
Queries the current debug level. Returns true if the debug listener is interested in debug information of this given level. This can be used to speed up certain complex debug displaying operations where the debug listener isn't interested in the information be presented.- Specified by:
isInterestedIn
in interfaceDebugLogger
-
write
public final void write(int level, java.lang.Object ob, java.lang.String message)
Description copied from interface:DebugLogger
This writes the given debugging string. It filters out any messages that are below the 'debug_level' variable. The 'object' variable specifies the object that made the call. 'level' must be between 0 and 255. A message of 'level' 255 will always print.- Specified by:
write
in interfaceDebugLogger
-
write
public final void write(int level, java.lang.Class cla, java.lang.String message)
- Specified by:
write
in interfaceDebugLogger
-
write
public final void write(int level, java.lang.String class_string, java.lang.String message)
- Specified by:
write
in interfaceDebugLogger
-
writeException
public final void writeException(java.lang.Throwable e)
Description copied from interface:DebugLogger
This writes the given Exception. Exceptions are always output to the log stream.- Specified by:
writeException
in interfaceDebugLogger
-
writeException
public final void writeException(int level, java.lang.Throwable e)
Description copied from interface:DebugLogger
This writes the given Exception but gives it a 'debug_level'. This is so we can write out a warning exception.- Specified by:
writeException
in interfaceDebugLogger
-
-