Class Debugger
- java.lang.Object
-
- com.sun.identity.cli.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 Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
error(CommandManager mgr, String msg)
Prints error messages only when debug level is greater than DEBUG.OFF.static void
error(CommandManager mgr, String msg, Throwable t)
Prints error messages only if debug state is greater than Debug.OFF.static String
getStackTrace(Throwable e)
Returns stack trace of an exception.static void
message(CommandManager mgr, String msg)
Prints messages only when the debug state is either Debug.MESSAGE or Debug.ON.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.static void
warning(CommandManager mgr, String msg)
Prints warning messages only when debug level is greater than Debug.ERROR.static void
warning(CommandManager mgr, String msg, Throwable t)
Prints warning messages only when debug level is greater than Debug.ERROR.
-
-
-
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 invokingmessageEnabled()
before invoking anymessage()
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 invokedestroy()
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 invokingmessageEnabled()
before invoking anymessage()
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 toSystem.out
or to the debug file. Ifmsg
is null, it is ignored.t
-Throwable
, on whichprintStackTrace
will be invoked to print the stack trace. Ift
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 invokingwarningEnabled()
before invoking anywarning()
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 toSystem.out
or to the debug file. Ifmsg
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 invokingwarningEnabled()
before invoking anywarning()
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 invokedestroy()
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 toSystem.out
or to the debug file. Ifmsg
is null, it is ignored.t
-Throwable
, on whichprintStackTrace()
will be invoked to print the stack trace. Ift
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 toSystem.out
or to the debug file. Ifmsg
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 onSystem.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 invokedestroy()
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 toSystem.out
or to the debug file. Ifmsg
is null, it is ignored.t
-Throwable
, on whichprintStackTrace()
will be invoked to print the stack trace. Ift
is null, it is ignored.
-
-