|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.concord.util.Debug
Debug contains useful code and constants for debugging.
There are two methods that developers are expected to use for routine debugging support during development. Assert() is used to test a condition and, if the condition fails, log the message and terminate the thread that called it. It should only be used in situations where failing the test is a catastrophic condition. Its function does NOT change between debug and release versions. The log() method will log an arbitrary string, and is conditioned on a passed in "level" integer. See the log level defintions below for information on what level to use and when.
Field Summary | |
static int |
BENGINE
|
static int |
BTEST
|
static boolean |
debug
|
static boolean |
DEBUG
Debug constant. |
static int |
ERROR
|
static int |
INFO
|
static int |
NONE
Constants used for the log level and in calls to log(). |
static int |
UTIL
|
static int |
WARNING
|
Constructor Summary | |
Debug()
|
Method Summary | |
static void |
addDebugging(java.lang.String token)
|
static void |
assert(boolean test,
java.lang.String message,
java.lang.Object obj)
The classic assert - if the test fails, prints a message and throws an Error. |
static int |
getLogLevel()
Get the log level. |
protected static java.io.PrintWriter |
getPrintWriter()
|
protected static java.io.PrintWriter |
getPrintWriter2()
|
static boolean |
isDebugging(java.lang.Object object,
java.lang.String token)
|
static boolean |
isDebugging(java.lang.String token)
|
static boolean |
isPartialMatch()
|
static void |
log(int messageLevel,
java.lang.String message,
java.lang.Object obj)
Log a debug string to the system output if the passed in log level is LOWER than or equal to the current log level OR if the Debug log level is greater than INFO, the level passed in is INFO or less or equal to the current Debug log level. |
static void |
println(java.lang.String message)
Print out a message to our output stream. |
static void |
printStackTrace(java.lang.Throwable e)
Print a stack trace for the exception passed in to the logging stream. |
static void |
removeDebugging(java.lang.String token)
|
static void |
setDebug(boolean value)
|
static void |
setDebugInstance(Debug newInstance)
Set the instance of Debug that we use when calling writeString() - this allows writeString() to be overridden for situations where there are no streams (e.g. |
static void |
setLogLevel(int level)
Set the log level. |
static void |
setPartialMatch(boolean partial)
|
static void |
setPrintWriter(java.io.PrintWriter pw,
boolean closeWhenDone)
Set the printStream to print logging output to. |
static void |
setPrintWriter2(java.io.PrintWriter pw2,
boolean closeWhenDone)
Set the printStream2 to print logging output to. |
protected void |
writeString(java.lang.String message,
java.lang.Object obj)
Send a string to our print stream for debugging purposes. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final boolean DEBUG
Set this to true for normal, debuggable builds.
Set this to false for release, non-debuggable builds.
When this is false, the compiler will eliminate any code wrapped in if(debug) { ... }.
public static boolean debug
public static final int NONE
public static final int ERROR
public static final int WARNING
public static final int INFO
public static final int UTIL
public static final int BTEST
public static final int BENGINE
Constructor Detail |
public Debug()
Method Detail |
public static void setDebug(boolean value)
public static void addDebugging(java.lang.String token)
public static void removeDebugging(java.lang.String token)
public static boolean isDebugging(java.lang.Object object, java.lang.String token)
public static boolean isDebugging(java.lang.String token)
public static void setPartialMatch(boolean partial)
public static boolean isPartialMatch()
public static final void assert(boolean test, java.lang.String message, java.lang.Object obj) throws java.lang.Error
test
- Boolean which is the result of the test you passed inmessage
- String which can be whatever you like to indicate what failedobj
- Object associated with message, normally 'this', may be null for staticspublic static final int getLogLevel()
public static final void setLogLevel(int level)
level
- Level to which the logging system should be set (duh).public static final void log(int messageLevel, java.lang.String message, java.lang.Object obj) throws java.lang.Error
messageLevel
- The logging level of this log message.message
- The String which is the message itself.java.lang.Error
- - if the error reported is catastrophic, no one should catch thispublic static final void println(java.lang.String message)
public static final void printStackTrace(java.lang.Throwable e)
e
- Throwable - exception to print stack trace forpublic static final void setDebugInstance(Debug newInstance)
newInstance
- Debug - instance of Debug (or subclass) to usepublic static final void setPrintWriter(java.io.PrintWriter pw, boolean closeWhenDone)
pw
- PrintWriter - new print writer, may be nullcloseWhenDone
- boolean - should the print writer be closed when a new one is set?public static final void setPrintWriter2(java.io.PrintWriter pw2, boolean closeWhenDone)
pw2
- PrintWriter - new print writer 2, may be nullcloseWhenDone
- boolean - should the print writer be closed when a new one is set?protected static final java.io.PrintWriter getPrintWriter()
protected static final java.io.PrintWriter getPrintWriter2()
protected void writeString(java.lang.String message, java.lang.Object obj)
message
- String to be output.obj
- Object whose name will be prepended to the message.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |