Class 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.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int debug_level
      This variable specifies the level of debugging information that is output.
      private java.lang.Object debug_lock
      The debug lock object.
      private java.io.PrintWriter err
      The print stream where the error information is output to.
      private java.io.PrintWriter out
      The print stream where the debugging information is output to.
      private static boolean PRINT_ALERT_TO_MESSAGES
      Set this to true if all alerts to messages are to be output to System.out.
      (package private) static java.io.PrintWriter SYSTEM_ERR
      The PrintWriter for the system error stream.
      (package private) static java.io.PrintWriter SYSTEM_OUT
      The PrintWriter for the system output stream.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void internalWrite​(java.io.PrintWriter out, int level, java.lang.String class_string, java.lang.String message)
      Internal method that writes out the given information on the output stream provided.
      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.
      private void writeTime()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • PRINT_ALERT_TO_MESSAGES

        private static final boolean PRINT_ALERT_TO_MESSAGES
        Set this to true if all alerts to messages are to be output to System.out. The purpose of this flag is to aid debugging.
        See Also:
        Constant Field Values
      • debug_lock

        private final java.lang.Object debug_lock
        The debug lock object.
      • SYSTEM_OUT

        static final java.io.PrintWriter SYSTEM_OUT
        The PrintWriter for the system output stream.
      • SYSTEM_ERR

        static final java.io.PrintWriter SYSTEM_ERR
        The PrintWriter for the system error stream.
      • debug_level

        private int debug_level
        This variable specifies the level of debugging information that is output. Any debugging output above this level is output.
      • out

        private java.io.PrintWriter out
        The print stream where the debugging information is output to.
      • err

        private java.io.PrintWriter err
        The print stream where the error information is output to.
    • Constructor Detail

      • DefaultDebugLogger

        public DefaultDebugLogger()
    • Method Detail

      • internalWrite

        private final void internalWrite​(java.io.PrintWriter out,
                                         int level,
                                         java.lang.String class_string,
                                         java.lang.String message)
        Internal method that writes out the given information on the output stream provided.
      • 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 interface DebugLogger
      • 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 interface DebugLogger
      • write

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

        public final void write​(int level,
                                java.lang.String class_string,
                                java.lang.String message)
        Specified by:
        write in interface DebugLogger
      • writeTime

        private final void writeTime()
      • 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 interface DebugLogger
      • 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 interface DebugLogger