Class DefaultDebugLogger

java.lang.Object
com.mckoi.debug.DefaultDebugLogger
All Implemented Interfaces:
DebugLogger, Lvl

public class DefaultDebugLogger extends 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 Details

    • DefaultDebugLogger

      public DefaultDebugLogger()
  • Method Details

    • setOutput

      public final void setOutput(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 interface DebugLogger
    • write

      public final void write(int level, Object ob, 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 interface DebugLogger
    • write

      public final void write(int level, Class cla, String message)
      Specified by:
      write in interface DebugLogger
    • write

      public final void write(int level, String class_string, String message)
      Specified by:
      write in interface DebugLogger
    • writeException

      public final void writeException(Throwable e)
      Description copied from interface: DebugLogger
      This writes the given Exception. Exceptions are always output to the log stream.
      Specified by:
      writeException in interface DebugLogger
    • writeException

      public final void writeException(int level, 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 interface DebugLogger