Class Debugger


  • public class Debugger
    extends Object
    This class is responsible for printing debug message to standard output if the --debug option is set in the command line.
    • Method Detail

      • message

        public static void message​(CommandManager mgr,
                                   String msg)
        Prints messages only when the debug state is either Debug.MESSAGE or Debug.ON.

        NOTE: Debugging is an IO intensive operation and may hurt application performance when abused. Particularly, note that Java evaluates arguments to message() even when debugging is turned off. So when the argument to this method involves the String concatenation operator '+' or any other method invocation, messageEnabled MUST be used. It is recommended that the debug state be checked by invoking messageEnabled() before invoking any message() methods to avoid unnecessary argument evaluation and maximize application performance.

        Parameters:
        mgr - Command Manager Object.
        msg - debug message.
        See Also:
        Debug.message(String, Throwable)
      • message

        public static void message​(CommandManager mgr,
                                   String msg,
                                   Throwable t)

        Prints debug and exception messages only when the debug state is either Debug.MESSAGE or Debug.ON. If the debug file is not accessible and debugging is enabled, the message along with a time stamp and thread info will be printed on System.out.

        This method creates the debug file if does not exist; otherwise it starts appending to the existing debug file. When invoked for the first time on this object, the method writes a line delimiter of '*'s.

        Note that the debug file will remain open until destroy() is invoked. To conserve file resources, you should invoke destroy() explicitly rather than wait for the garbage collector to clean up.

        NOTE: Debugging is an IO intensive operation and may hurt application performance when abused. Particularly, note that Java evaluates arguments to message() even when debugging is turned off. It is recommended that the debug state be checked by invoking messageEnabled() before invoking any message() methods to avoid unnecessary argument evaluation and to maximize application performance.

        Parameters:
        mgr - Command Manager Object.
        msg - message to be printed. A newline will be appended to the message before printing either to System.out or to the debug file. If msg is null, it is ignored.
        t - Throwable, on which printStackTrace will be invoked to print the stack trace. If t is null, it is ignored.
        See Also:
        Debug.error(String, Throwable)
      • warning

        public static void warning​(CommandManager mgr,
                                   String msg)
        Prints warning messages only when debug level is greater than Debug.ERROR.

        NOTE: Debugging is an IO intensive operation and may hurt application performance when abused. Particularly, note that Java evaluates arguments to warning() even when debugging is turned off. So when the argument to this method involves the String concatenation operator '+' or any other method invocation, warningEnabled MUST be used. It is recommended that the debug state be checked by invoking warningEnabled() before invoking any warning() methods to avoid unnecessary argument evaluation and to maximize application performance.

        Parameters:
        mgr - Command Manager Object.
        msg - message to be printed. A newline will be appended to the message before printing either to System.out or to the debug file. If msg is null, it is ignored.
        See Also:
        Debug.warning(String, Throwable)
      • warning

        public static void warning​(CommandManager mgr,
                                   String msg,
                                   Throwable t)
        Prints warning messages only when debug level is greater than Debug.ERROR.

        NOTE: Debugging is an IO intensive operation and may hurt application performance when abused. Particularly, note that Java evaluates arguments to warning() even when debugging is turned off. It is recommended that the debug state be checked by invoking warningEnabled() before invoking any warning() methods to avoid unnecessary argument evaluation and to maximize application performance.

        If the debug file is not accessible and debugging is enabled, the message along with a time stamp and thread info will be printed on System.out.

        This method creates the debug file if does not exist; otherwise it starts appending to the existing debug file. When invoked for the first time on this object, the method writes a line delimiter of '*'s.

        Note that the debug file will remain open until destroy() is invoked. To conserve file resources, you should invoke destroy() explicitly rather than wait for the garbage collector to clean up.

        Parameters:
        mgr - Command Manager Object.
        msg - message to be printed. A newline will be appended to the message before printing either to System.out or to the debug file. If msg is null, it is ignored.
        t - Throwable, on which printStackTrace() will be invoked to print the stack trace. If t is null, it is ignored.
      • error

        public static void error​(CommandManager mgr,
                                 String msg)
        Prints error messages only when debug level is greater than DEBUG.OFF.
        Parameters:
        mgr - Command Manager Object.
        msg - message to be printed. A newline will be appended to the message before printing either to System.out or to the debug file. If msg is null, it is ignored.
        See Also:
        Debug.error(String, Throwable)
      • error

        public static void error​(CommandManager mgr,
                                 String msg,
                                 Throwable t)
        Prints error messages only if debug state is greater than Debug.OFF. If the debug file is not accessible and debugging is enabled, the message along with a time stamp and thread info will be printed on System.out.

        This method creates the debug file if does not exist; otherwise it starts appending to the existing debug file. When invoked for the first time on this object, the method writes a line delimiter of '*'s.

        Note that the debug file will remain open until destroy() is invoked. To conserve file resources, you should invoke destroy() explicitly rather than wait for the garbage collector to clean up.

        Parameters:
        mgr - Command Manager Object.
        msg - message to be printed. A newline will be appended to the message before printing either to System.out or to the debug file. If msg is null, it is ignored.
        t - Throwable, on which printStackTrace() will be invoked to print the stack trace. If t is null, it is ignored.
      • getStackTrace

        public static String getStackTrace​(Throwable e)
        Returns stack trace of an exception.
        Parameters:
        e - Exception object.
        Returns:
        Stack trace of an exception.