[.home.]
[.hacks.]
[.java.]

Class Debug

java.lang.Object
  |
  +--Debug

public class Debug
extends java.lang.Object

(#)Debug.java

Version:
3.2 19-Mar-2004

Standalone class with static methods to aid with debugging. Debugging output can be controlled with different methods:

1) By specifying the class with should be debugged
2) By specifying an optional "level" with should be debugged
3) By specifying the "warning" flag
The format can be controlled via some flags

1) Thread (p): Shows the name of the current Thread
2) Location (l): Shows the location within the source file
3) Time (t): Shows the current time including millisec.
4) Delta (d): Shows the time delta from the last debugging output
5) Warning (w): Shows warning messages (see above)
6) Method (m): Shows the name of the current method
7) Class (c): Shows the class name

Location printing only works correct if there is no JIT Compiler active.
Author:
Holger Pfaff

Constructor Summary
Debug()
           
 
Method Summary
static java.lang.String cname(java.lang.Object o)
          put out a classname if requested
static void debug(java.lang.Object o)
          Debug object o if object o is to debug - no additional message
static void debug(java.lang.Object o, java.lang.Object m)
          Debug object o if object o is to debug on all levels - add message m
static void debug(java.lang.Object l, java.lang.Object o, java.lang.Object m)
          Debug object o if object o and level l is to debug - add message m
static void error(java.lang.Object m)
          Report an error
static java.lang.String getClassName(java.lang.Object o)
          Return classname of Object. o ist eiter:
- a Class object
- a String containing the class name
- or the Object itself
static boolean isClass(java.lang.Object o)
          Check if class o was requested to debug.
static boolean isLevel(java.lang.Object l)
          Check if level l was requested to debug.
static java.lang.String msg(java.lang.Exception x)
          format the error msg
static java.lang.String msg(java.lang.Object o)
          format the error msg
static void println(java.lang.String p, java.lang.Object m)
          print a debug string
static void setArgs(java.lang.String a)
          Configure debugging from command line arg.
static void setClass(java.lang.Class c, boolean a)
          Set/unset debugging classes
static void setClass(java.lang.String c, boolean a)
          Set/unset debugging classes
static void setFlags(java.lang.String f, boolean b)
          Set debugging flags
static void setLevel(java.lang.String l, boolean a)
          Set/unset debugging levels
static java.lang.String stack(java.lang.Exception X)
          return stack trace as string
static java.lang.String[] stackline(int s)
          return specific stackline - 0 is where exception occured
static java.lang.String stackline2loc(java.lang.String[] l)
          extract location in source from stackline
static java.lang.String stackline2meth(java.lang.String[] l)
          extract methodname from stackline
static java.lang.String thread()
          put out a threadname if requested
static java.lang.String time()
          put out a timestamp if requested
static java.lang.String toString(java.lang.String p, java.lang.Object m)
          form a debug string
static void warn(java.lang.Object m)
          Report a warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Debug

public Debug()
Method Detail

setArgs

public static void setArgs(java.lang.String a)
Configure debugging from command line arg. Format shoud be: :,...:,... e.g. plt:*:Main shows thread name, locaton & time for any level (*) and class Main

Parameters:
a - the command line arg

setFlags

public static void setFlags(java.lang.String f,
                            boolean b)
Set debugging flags

Parameters:
f - flaf to set
b - set or re-set ?

setLevel

public static void setLevel(java.lang.String l,
                            boolean a)
Set/unset debugging levels

Parameters:
l - level to set/unset
a - set or unset?

setClass

public static void setClass(java.lang.String c,
                            boolean a)
Set/unset debugging classes

Parameters:
c - class to set/unset
a - set or unset?

setClass

public static void setClass(java.lang.Class c,
                            boolean a)
Set/unset debugging classes

Parameters:
c - class to set/unset
a - set or unset?

getClassName

public static java.lang.String getClassName(java.lang.Object o)
Return classname of Object. o ist eiter:
- a Class object
- a String containing the class name
- or the Object itself

Parameters:
o - object to return classname of
Returns:
classname of Object as string

error

public static void error(java.lang.Object m)
Report an error

Parameters:
m - usually the error message or Exception

warn

public static void warn(java.lang.Object m)
Report a warning

Parameters:
m - usually the warning message or Exception

debug

public static void debug(java.lang.Object o)
Debug object o if object o is to debug - no additional message

Parameters:
o - Object to debug

debug

public static void debug(java.lang.Object o,
                         java.lang.Object m)
Debug object o if object o is to debug on all levels - add message m

Parameters:
o - Object to debug
m - the message

debug

public static void debug(java.lang.Object l,
                         java.lang.Object o,
                         java.lang.Object m)
Debug object o if object o and level l is to debug - add message m

Parameters:
l - level
o - Object to debug
m - the message

isLevel

public static boolean isLevel(java.lang.Object l)
Check if level l was requested to debug.

Parameters:
l - level

isClass

public static boolean isClass(java.lang.Object o)
Check if class o was requested to debug.

Parameters:
o - class

toString

public static java.lang.String toString(java.lang.String p,
                                        java.lang.Object m)
form a debug string

Parameters:
p - prefix (e.g. timestamp)
m - the message
Returns:
a nice formatted string

println

public static void println(java.lang.String p,
                           java.lang.Object m)
print a debug string

Parameters:
p - prefix (e.g. timestamp)
m - the message

time

public static java.lang.String time()
put out a timestamp if requested


cname

public static java.lang.String cname(java.lang.Object o)
put out a classname if requested

Parameters:
o - object to put out classname for

thread

public static java.lang.String thread()
put out a threadname if requested


msg

public static java.lang.String msg(java.lang.Object o)
format the error msg

Parameters:
o - object to format

msg

public static java.lang.String msg(java.lang.Exception x)
format the error msg

Parameters:
x - Exception to format

stack

public static java.lang.String stack(java.lang.Exception X)
return stack trace as string


stackline

public static java.lang.String[] stackline(int s)
return specific stackline - 0 is where exception occured


stackline2meth

public static java.lang.String stackline2meth(java.lang.String[] l)
extract methodname from stackline


stackline2loc

public static java.lang.String stackline2loc(java.lang.String[] l)
extract location in source from stackline


[.home.]
[.hacks.]
[.java.]