public final class PsDebug
extends java.lang.Object
implements java.lang.Runnable
if (PsDebug.NOTIFY) PsDebug.notify(String) // Default: disabled in release version if (PsDebug.WARNING) PsDebug.warning(String) // Default: enabled PsDebug.error(String, PsObject) // Default: enabledand textual messages may be directly issued with
PsDebug.message(String) // Default: enabledAll information is collected in a text area and shown in the dialog
PsConsole
.
The checkboxes located in the header of the console allow to enable different warning levels.
Remark: All messages are cached and flushed to console after some short intervals.
Debug methods parse the current stack trace and print additional information about the calling method and class.
PsConsole
Modifier and Type | Field and Description |
---|---|
static boolean |
DEBUG
Determines if JavaView runs in debug mode.
|
static boolean |
ERROR
Global flag used during compile time to include or exclude all PsDebug.error() calls.
|
static int |
MAX_MESSAGE_LENGTH
Determines the message type 'message'.
|
static boolean |
MEMORY
Determines if JavaView performs memory measurements.
|
static boolean |
MESSAGE
Global flag used during compile time to include or exclude all PsDebug.message() calls.
|
static boolean |
NOTIFY
Global flag used during compile time to include or exclude all PsDebug.notify() calls.
|
static boolean |
STATUS
Global flag used during compile time to include or exclude all PsDebug.showStatus() calls.
|
static boolean |
WARNING
Global flag used during compile time to include or exclude all PsDebug.warning() calls.
|
Constructor and Description |
---|
PsDebug() |
Modifier and Type | Method and Description |
---|---|
static void |
beep(java.lang.String message)
Issue a beep and print message to System.out.
|
static void |
disposeConsole()
Dispose console window, e.g. when applet stops, remove textArea and reset variables.
|
static void |
error(java.lang.String aString)
Error messages indicate fatal errors which cannot be handled.
|
static void |
error(java.lang.String aString,
java.lang.Object what)
Error messages indicate fatal errors which cannot be handled.
|
static void |
flushMessages()
Flush cached messages into console window.
|
static PsConsole |
getConsole()
Get console window.
|
static java.awt.Rectangle |
getConsoleSize()
Get rectangle with size of JavaView console window.
|
static long |
getFlushInterval()
Get length of least time interval between two successive flushes.
|
static int |
getMaxNumBeeps()
Get maximal number of warning beeps.
|
static long |
getMemoryIncr()
Get amount of newly allocated memory since last call
of initMemory() or getMemoryIncr().
|
static long |
getMemoryTotal()
Get total amount of memory which is total memory minus free memory of current runtime.
|
static java.awt.Panel |
getStatusPanel()
Get panel which shows status information.
|
static long |
getTimeIncr()
Get number of milliseconds since last call of getIncrTime() or initTime().
|
static long |
getTimeUsed()
Get number of milliseconds since last call of initTime().
|
static boolean |
hasConsole()
Get state of console.
|
static boolean |
hasMessages()
Check whether message buffer contains non-flushed messages.
|
static void |
initMemory()
Compute initial amount of memory for use with getMemoryIncr().
|
static void |
initTime()
Initialize timer for use with getTimeUsed() and getTimeIncr().
|
static boolean |
isDebug()
Check switch if debugging is enabled.
|
static boolean |
isError()
Check switch to record heavy errors in JavaView console.
|
static boolean |
isMessage()
Check switch to record info message in JavaView console.
|
static boolean |
isNotify()
Check switch to record notify message, i.e. debug messages, in JavaView console.
|
static boolean |
isWarning()
Check switch to record warning messages in JavaView console.
|
static void |
message(java.lang.String aString)
Print messages immediately to console, make rare use since no button to turn it off.
|
static void |
message(java.lang.String aString,
boolean bShowConsole)
Print messages immediately to console, make rare use since no button to turn it off.
|
static void |
messageWithoutNewline(java.lang.String aString)
Print messages immediately to console, make rare use since no button to turn it off.
|
static void |
messageWithoutNewline(java.lang.String aString,
boolean bShowConsole)
Print messages immediately to console, make rare use since no button to turn it off.
|
static void |
notify(java.lang.String aString)
Heavily used during development process for all different messages.
|
static void |
outOfMemory(java.lang.OutOfMemoryError oom)
Issue an OutOfMemory warning and perform garbage collection.
|
static void |
popStatus()
Recall and show the previous status message.
|
static void |
pushStatus(java.lang.String aString)
Store previous status on stack and show this new status message.
|
static void |
pushStatus(java.lang.String aString,
int seconds)
Display message in status bar of applet, and in console window.
|
void |
run()
Flush messages collected with PsDebug to console.
|
static void |
setConsole(PsConsole console)
Set console.
|
static void |
setDebug(boolean aFlag)
Enable debugging.
|
static void |
setError(boolean aFlag)
Enable recording of heavy errors in JavaView console.
|
static void |
setMaxNumBeeps(int num)
Set maximal number of warning beeps.
|
static void |
setMessage(boolean aFlag)
Enable recording of info message in JavaView console.
|
static void |
setNotify(boolean aFlag)
Enable recording of notify message, i.e. debug messages, in JavaView console.
|
static void |
setWarning(boolean aFlag)
Enable recording of warning messages in JavaView console.
|
static void |
showStatus(java.lang.String aString)
Display message in status bar of applet, and in console window.
|
static void |
warning(java.lang.Exception ex,
java.lang.String aString)
Warning messages indicate real errors which are handled.
|
static void |
warning(java.lang.String aString)
Warning messages indicate real errors which are handled.
|
static void |
warning(java.lang.String aString,
java.lang.Object what)
Warning messages indicate real errors which are handled.
|
public static final boolean STATUS
STATUS==false
then all notification methods are removed by a Java
compiler during optimization since the methods would never be executed.
The Microsoft conditional directive is used to simplify the conditional switch, and the conditional statements can be removed without any influence if the developer sets the variable STATUS by hand.
public static final boolean MESSAGE
MESSAGE==false
then all notification methods are removed by a Java
compiler during optimization since the methods would never be executed.
The Microsoft conditional directive is used to simplify the conditional switch, and the conditional statements can be removed without any influence if the developer sets the variable MESSAGE by hand.
public static final boolean NOTIFY
NOTIFY==false
then all notification methods are removed by a Java
compiler during optimization since the methods would never be executed.
The Microsoft conditional directive is used to simplify the conditional switch, and the conditional statements can be removed without any influence if the developer sets the variable NOTIFY by hand.
public static final boolean WARNING
WARNING==false
then all warning methods are removed by a Java
compiler during optimization since the methods would never be executed.
The Microsoft conditional directive is used to simplify the conditional switch, and the conditional statements can be removed without any influence if the developer sets the variable WARNING by hand.
public static final boolean ERROR
ERROR==false
then all error methods are removed by a Java
compiler during optimization since the methods would never be executed.
The Microsoft conditional directive is used to simplify the conditional switch, and the conditional statements can be removed without any influence if the developer sets the variable ERROR by hand.
public static final boolean DEBUG
public static final boolean MEMORY
public static final int MAX_MESSAGE_LENGTH
public static PsConsole getConsole()
public static java.awt.Panel getStatusPanel()
public static void disposeConsole()
public static void setConsole(PsConsole console)
public static boolean hasConsole()
public static java.awt.Rectangle getConsoleSize()
public static boolean isMessage()
public static void setMessage(boolean aFlag)
public static boolean isNotify()
public static void setNotify(boolean aFlag)
public static boolean isWarning()
public static void setWarning(boolean aFlag)
public static boolean isError()
public static void setError(boolean aFlag)
public static boolean isDebug()
public static void setDebug(boolean aFlag)
public static long getFlushInterval()
public static boolean hasMessages()
public static final void flushMessages()
public static final void popStatus()
public static final void pushStatus(java.lang.String aString)
public static final void pushStatus(java.lang.String aString, int seconds)
aString
- status messagepublic void run()
run
in interface java.lang.Runnable
public static final void showStatus(java.lang.String aString)
aString
- status messagepublic static final void message(java.lang.String aString)
public static final void messageWithoutNewline(java.lang.String aString)
public static final void message(java.lang.String aString, boolean bShowConsole)
public static final void messageWithoutNewline(java.lang.String aString, boolean bShowConsole)
public static final void notify(java.lang.String aString)
public static final void warning(java.lang.String aString)
aString
- warning messagepublic static final void warning(java.lang.Exception ex, java.lang.String aString)
Print stack trace either of the method which invoked this warning method, or, if ex!=null print the stack trace of the exception.
ex
- Stack trace of exception is printed rather than of invocation of warning.aString
- warning messagepublic static final void warning(java.lang.String aString, java.lang.Object what)
aString
- warning messagewhat
- object containing more information, what.toString() is appended to messagepublic static final void error(java.lang.String aString)
PsDebug.error(String, Object)
with object==null
.
Console window pops up automatically if method is called.aString
- error messagepublic static final void error(java.lang.String aString, java.lang.Object what)
aString
- error message.what
- object containing more information, what.toString() is appended to message.public static int getMaxNumBeeps()
public static void setMaxNumBeeps(int num)
num
- maximal number of warning beeps.public static void beep(java.lang.String message)
The beep() method attempts to play an audio beep. You have no control over pitch, duration, or volume; it is like putting echo ^G in a UNIX shell script.
If run as application this method calls the beep method of the default toolkit. If run as applet then a beep from an audio file is played (pending).
Method is called if an error occurs, or, when in debug mode, also if a warning occurs. Information about the beep is given in the console window of JavaView.
public static void initTime()
public static long getTimeUsed()
public static long getTimeIncr()
public static void initMemory()
public static long getMemoryTotal()
public static long getMemoryIncr()
public static void outOfMemory(java.lang.OutOfMemoryError oom)
"