|
|||||||||
| Home >> All >> com >> port80 >> [ util overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
com.port80.util
Class Debug

java.lang.Objectcom.port80.util.Debug
- public class Debug
- extends java.lang.Object
Debug mode and related utilities to selectively enable specific debug modes.
Debug.set('*') enables all debug modes. Modes 'debug','trace','test','verbose','check'
exists by default (but disabled except 'test' is default enabled) on startup
and after Debug.clear().
Builtin modes:
debug Turns on debug messages.
trace Turns on trace messages.
test Turns on test messages, which are temporary and would normally remove
from source code after the testing.
verbose Turns on verbose messages during normal execution.
check Turns on check mode code, which provide additional sanity checkings that
normal execution should skip.
USAGE:
. Note that all data and methods are static.
. For class that have custom debug mode, it should add the mode in a static initialization block:
static { Debug.add("package.classname"); }
The added mode by default is disabled. However, if the mode already exist add() would not change
its enable/disable state.
. The main program is responsible for enabling the specific debug modes by the enable() method.
Since the static initialization are executed when the class is loaded, it may be initialized
after the main program command line processing. The command line processing can enable specific
modes, in that case, the static initialization would be change the enable/disable state.
The command line processing call enable() with a wildcard ('*') pattern. In that case, the
modes that match the pattern would be enabled when it is added.
enable("specific-mode"); // Enable a single mode.
enable("wildcard*pattern"); // Enable all existing and future added modes that match the pattern.
. There is also disable() methods, however, they should be used sparsely when really neccessary.
If there are contradicting enable and disable wildcard patterns, the result is undetermined.
. It is the main program's main method repsonsible for enable/disable debugging of a particular module
(after checking command line options).
. Each module check (static) whether it is required to run in debug mode:
public static boolean DEBUG=Debug.isEnabled(
Field Summary
private static java.lang.BooleanDISABLE
private static java.lang.BooleanENABLE
private static java.util.MaptheDefaults
private static java.util.MaptheModes
Constructor Summary
Debug()
Method Summary
static voidadd(java.lang.String mode)
Add a mode, by default disabled.
static voidadd(java.lang.String s,
boolean on)
Add a mode and optionally enable it.
static booleancheck()
static voidclear()
static booleandebug()
static voiddisable(java.util.List modes)
Disable a list of debug mode.
static voiddisable(java.lang.String modes)
static voidenable(java.util.List modes)
Enable a list of debug modes.
static voidenable(java.lang.String modes)
static booleanget(java.lang.String s)
static java.util.ListgetDisables()
Return the name of all debug modes that are disabled.
static java.util.ListgetEnables()
Return the name of all debug modes that are enabled.
static java.util.ListgetModes()
Return the name of all declared debug modes.
private static voidinit()
static booleanisCheck()
static booleanisDebug()
static booleanisEnabled(java.lang.String s)
static booleanisOn()
static booleanisTest()
static booleanisTrace()
static booleanisVerbose()
static booleanon()
static voidreset(java.lang.String s)
static voidset(java.lang.String s)
Same as enable(),disable(),isEnabled(),isDebug()...etc.
static booleantest()
static booleantrace()
static booleanverbose()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Field Detail
ENABLE
private static final java.lang.Boolean ENABLE
DISABLE
private static final java.lang.Boolean DISABLE
theModes
private static java.util.Map theModes
theDefaults
private static java.util.Map theDefaults
Constructor Detail
Debug
public Debug()
Method Detail
clear
public static void clear()
enable
public static void enable(java.util.List modes)
enable
public static void enable(java.lang.String modes)
disable
public static void disable(java.util.List modes)
disable
public static void disable(java.lang.String modes)
add
public static void add(java.lang.String mode)
add
public static void add(java.lang.String s,
boolean on)
getModes
public static java.util.List getModes()
getEnables
public static java.util.List getEnables()
getDisables
public static java.util.List getDisables()
isEnabled
public static boolean isEnabled(java.lang.String s)
isOn
public static boolean isOn()
isDebug
public static boolean isDebug()
isTrace
public static boolean isTrace()
isTest
public static boolean isTest()
isVerbose
public static boolean isVerbose()
isCheck
public static boolean isCheck()
set
public static void set(java.lang.String s)
reset
public static void reset(java.lang.String s)
get
public static boolean get(java.lang.String s)
on
public static boolean on()
debug
public static boolean debug()
trace
public static boolean trace()
test
public static boolean test()
verbose
public static boolean verbose()
check
public static boolean check()
init
private static void init()
Overview
Package
Class
Use
Deprecated
Index
Home >> All >> com >> port80 >> [ util overview ]
PREV CLASS NEXT CLASS
SUMMARY:
JAVADOC |
SOURCE |
DOWNLOAD | NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
com.port80.util.Debug