|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.mozilla.util.Debug
public class Debug
Vendor of debug "filter" strings set & queried by clients. This allows conditional code to only be executed if a certain filter is set.
Example of use from JAG days:JDApplication allows the setting of filters from the commandline at app startup time, and Log supports printing debug messages only when a specific filter string has been set.
Alternatively, users can use the System Properties table to define filter strings at runtime:
java -DDebug.filters=String ...
where String is comma (,) separated list of constants WITH NO WHITESPACE. ie "AXISPANEL_PAINT,BODYPANEL_PAINT".
All filters are case-sensitive.
This class also provides various timing routines.
Field Summary | |
---|---|
static java.lang.String |
ALL_FILTER_STRING
|
static java.lang.String |
HELP_FILTER_STRING
|
static boolean |
keepWaiting
|
static java.lang.String |
PROGRESS_FILTER_STRING
|
static java.lang.String |
TIMING_FILTER_STRING
|
Constructor Summary | |
---|---|
Debug()
|
Method Summary | |
---|---|
static void |
addFilter(java.lang.String aFilter)
Sets a debug filter, for future consumption by this class, as well as other utility classes, like Log, etc. |
static boolean |
containsFilter(java.lang.String aFilter)
Returns true if any of the following conditions are true. |
static boolean |
containsFilter(java.lang.String aFilter,
java.lang.String allFiltersgMatchThisString)
Funnel-point method, which takes a filter and an "allFiltersgMatchThisString" string. |
static boolean |
containsFilterWithPrefix(java.lang.String aFilterPrefix)
Look for any "filter" with the specified prefix. |
static void |
elapsedTime(java.lang.String logMessage)
Identical to the "elapsedTime(String logMessage, String aFilter)" method, except it will only show the message if the filter "TIMING" exists in Debug's filter list. |
static void |
elapsedTime(java.lang.String logMessage,
java.lang.String aFilter)
This method does absolutely nothing unless one or more of the following conditions are met. |
static long |
elapsedTimeSinceElapsedTime()
Returns the elapsed time since this class was initialized. |
static long |
elapsedTimeSinceInitialization()
Returns the elapsed time since this class was initialized. |
static long |
elapsedTimeSinceStartTime()
Returns the elapsed time since the preceeding startTiming() call. |
static java.lang.String |
getHashCode(java.lang.Object anObject)
Returns a String containing the hexadecimal hashCode of the passed in object, of the form: "0x0000". |
static java.lang.String |
getNameAndHashCode(java.lang.Object anObject)
Returns a String containing the class name and hexadecimal hashCode of the passed in object, of the form: "fully.qualified.ClassName[0x0000]". |
static void |
printTime(java.lang.String msg,
java.lang.String aFilter)
Print time since start of app, and time since the last time this method was called. |
static void |
removeAllFilters()
Removes all filters from the list of filters. |
static void |
removeFilter(java.lang.String aFilter)
Removes the specified filter from the list of filters. |
static void |
startTiming()
Starts a timer which can be stopped using one of the "stopTiming()" methods. |
static void |
startTiming(java.lang.String logMessage)
Identical to the "startTiming(String logMessage, String aFilter)" method, except it will only show the message if the filter "TIMING" exists in Debug's filter list. |
static void |
startTiming(java.lang.String logMessage,
java.lang.String aFilter)
This method does absolutely nothing unless one or more of the following conditions are met. |
static void |
waitForDebugger()
Wait until a debugger attaches. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String HELP_FILTER_STRING
public static final java.lang.String ALL_FILTER_STRING
public static final java.lang.String TIMING_FILTER_STRING
public static final java.lang.String PROGRESS_FILTER_STRING
public static boolean keepWaiting
Constructor Detail |
---|
public Debug()
Method Detail |
---|
public static void waitForDebugger()
Wait until a debugger attaches.
Usage:
Place a call to this method in the earliest possible entry point of your servlet app. It will cause the app to enter into an infinite loop, sleeping until the static var keepWaiting is set to false. The idea is that you attach your debugger to the servlet, then, set a breakpont in this method. When it is hit, you use the debugger to set the keepWaiting class var to false.
public static void addFilter(java.lang.String aFilter)
Sets a debug filter, for future consumption by this class, as well as other utility classes, like Log, etc.
Virtually all "filters" are simply developer-meaningful strings which will be tested within developer code, to conditionally execute code.
There are some predefined filters, which this class actually does something with (besides simply handing it back when asked for).
The predefined filters are:
HELP
ALL
TIMING
If the "HELP" filter is found, this class will print a message displaying the predefined filters and what they do.
If the "ALL" filter is found, this class will return "true" when queried for the existence of any filter, effectively turning on all debugging tests. This is useful for both quick and easy tests, as well as to find forgotten debug filters (see Log class for more info on this).
If the "TIMING" filter is specified, then the time routines will always print their info, regardless of what filter string is passed to them. This is useful for turning on all timing tests.
public static void removeFilter(java.lang.String aFilter)
public static void removeAllFilters()
public static boolean containsFilterWithPrefix(java.lang.String aFilterPrefix)
Look for any "filter" with the specified prefix.
"ALL" is not considered to be a match.
This method works in (normally) O-n time (if no match).
public static boolean containsFilter(java.lang.String aFilter, java.lang.String allFiltersgMatchThisString)
Funnel-point method, which takes a filter and an "allFiltersgMatchThisString" string. See the javadoc for "containsFilter(String aFilter)" for the rest of what this method does.
This method works in (normally) O-1 time.
NOTE: The "allFiltersgMatchThisString" parameter can be used to conditionally execute code while preventing the "ALL" filter from having any effect. So, the conditional code should use the test "if (Debug.containsFilter("SomeFilter", ""))" to see if a filter has been set, and not get a false positive from the "ALL" filter.
public static boolean containsFilter(java.lang.String aFilter)
Returns true if any of the following conditions are true.
Otherwise returns false.
NOTE: This method, and all filtering of this class is case-sensitive.
public static void startTiming()
Starts a timer which can be stopped using one of the "stopTiming()" methods.
This method does not check debug filters... it always does what it's told.
Calling this method resets the elapsed time ("lap time").
public static void startTiming(java.lang.String logMessage)
Identical to the "startTiming(String logMessage, String aFilter)" method, except it will only show the message if the filter "TIMING" exists in Debug's filter list.
public static void startTiming(java.lang.String logMessage, java.lang.String aFilter)
This method does absolutely nothing unless one or more of the following conditions are met.
NOTE: The "ALL" filter has no effect on timing methods.
Otherwise, starts a timer which can be stopped using one of the "stopTiming()" methods and prints out a logMessage indicating that timing has begun.
This method may be called with a "null" logMessage. A logMessage is sometimes unneccesary since the matched filter string is printed with the output anyway, and that is frequently enough information.
Calling this method resets the elapsed time ("lap time").
public static long elapsedTimeSinceInitialization()
Returns the elapsed time since this class was initialized.
This method does not check debug filters... it always does what it's told.
Calling this method resets the elapsed time ("lap time").
This method may be called repeatedly to get "lap" times.
public static long elapsedTimeSinceStartTime()
Returns the elapsed time since the preceeding startTiming() call. This method does not check debug filters... it always does what it's told. Calling this method resets the elapsed time ("lap time"). This method may be called repeatedly to get "lap" times.
public static long elapsedTimeSinceElapsedTime()
Returns the elapsed time since this class was initialized.
This method does not check debug filters... it always does what it's told.
Calling this method resets the elapsed time ("lap time").
This method may be called repeatedly to get "lap" times.
public static void elapsedTime(java.lang.String logMessage)
Identical to the "elapsedTime(String logMessage, String aFilter)" method, except it will only show the message if the filter "TIMING" exists in Debug's filter list.
public static void elapsedTime(java.lang.String logMessage, java.lang.String aFilter)
This method does absolutely nothing unless one or more of the following conditions are met.
NOTE: The "ALL" filter has no effect on timing methods.
Otherwise, prints the following information:
When a filter matches, this method invokes the following methods:
elapsedTime()
elapsedTimeSinceInitialization()
elapsedTimeSinceElapsedTime()
When a filter matches, calling this method resets the elapsed time ("lap time").
This method may be called with a "null" logMessage. A logMessage is sometimes unneccesary since the matched filter string is printed with the output anyway, and that is frequently enough information.
This method may be called repeatedly to get "lap" times.
public static void printTime(java.lang.String msg, java.lang.String aFilter)
Print time since start of app, and time since the last time this method was called. Call this with a msg you want printed, and a filter. Then run with -jsdebug filter and all these timing msgs will come out.
public static java.lang.String getHashCode(java.lang.Object anObject)
Returns a String containing the hexadecimal hashCode of the passed in object, of the form: "0x0000".
public static java.lang.String getNameAndHashCode(java.lang.Object anObject)
Returns a String containing the class name and hexadecimal hashCode of the passed in object, of the form: "fully.qualified.ClassName[0x0000]".
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |