public class Debug
extends java.lang.Object
Debug now automatically figures out which class it was called from, so all methods passing in the calling class are deprecated.
The defaults are to print all messages to stderr with class and method name.
Should be called like this:
if (Debug.debug) Debug.print(Debug.INFO, "Debug Message");
Modifier and Type | Class and Description |
---|---|
static interface |
Debug.FilterCommand
This interface can be used to provide custom printing filters
for certain classes.
|
Modifier and Type | Field and Description |
---|---|
static int |
CRIT
Highest priority messages
|
static boolean |
debug
Set this to false to disable compilation of Debug statements
|
static int |
DEBUG
Debug messages
|
static java.io.PrintStream |
debugout
The current output stream (defaults to System.err)
|
static int |
ERR
Error messages
|
static int |
INFO
Information
|
static int |
VERBOSE
Verbose debug messages
|
static int |
WARN
Warnings
|
Constructor and Description |
---|
Debug() |
Modifier and Type | Method and Description |
---|---|
static void |
addFilterCommand(java.lang.Class c,
Debug.FilterCommand f)
Add a filter command for a specific type.
|
static boolean |
debugging(java.lang.Class c,
int loglevel)
Deprecated.
In Java 1.5 calling class is automatically identified, no need to pass it in.
|
static boolean |
debugging(java.lang.String s,
int loglevel) |
static void |
loadConfig(java.io.File f)
Read which class to debug on at which level from the given File.
|
static void |
print(java.lang.Class c,
int loglevel,
java.lang.Object d)
Deprecated.
In Java 1.5 calling class is automatically identified, no need to pass it in.
|
static void |
print(java.lang.Class c,
int loglevel,
java.lang.String s)
Deprecated.
In Java 1.5 calling class is automatically identified, no need to pass it in.
|
static void |
print(java.lang.Class c,
int loglevel,
java.lang.Throwable t)
Deprecated.
In Java 1.5 calling class is automatically identified, no need to pass it in.
|
static void |
print(int loglevel,
byte[] b)
Log a byte array
|
static void |
print(int loglevel,
java.lang.Object o)
Log an Object
|
static void |
print(int loglevel,
java.lang.String s)
Log a String
|
static void |
print(int loglevel,
java.lang.Throwable t)
Log a Throwable
|
static void |
print(java.lang.Object d)
Log at DEBUG
|
static void |
print(java.lang.Object o,
int loglevel,
java.lang.Object d)
Deprecated.
In Java 1.5 calling class is automatically identified, no need to pass it in.
|
static void |
print(java.lang.Object o,
int loglevel,
java.lang.String s)
Deprecated.
In Java 1.5 calling class is automatically identified, no need to pass it in.
|
static void |
print(java.lang.Object o,
int loglevel,
java.lang.Throwable t)
Deprecated.
In Java 1.5 calling class is automatically identified, no need to pass it in.
|
static void |
print(java.lang.Object o,
java.lang.Object d)
Deprecated.
In Java 1.5 calling class is automatically identified, no need to pass it in.
|
static void |
printMap(java.lang.Class c,
int loglevel,
java.util.Map m)
Deprecated.
In Java 1.5 calling class is automatically identified, no need to pass it in.
|
static void |
printMap(int loglevel,
java.util.Map m)
Log a Map
|
static void |
printMap(java.util.Map m)
Log a Map at DEBUG log level
|
static void |
printMap(java.lang.Object o,
int loglevel,
java.util.Map m)
Deprecated.
In Java 1.5 calling class is automatically identified, no need to pass it in.
|
static void |
setByteArrayCount(int count)
Set the size of hexdumps.
|
static void |
setByteArrayWidth(int width)
Set the formatted width of hexdumps.
|
static void |
setHexDump(boolean hexdump)
Enable or disable hexdumps.
|
static void |
setLineNos(boolean lines)
Enable or disable line numbers.
|
static void |
setOutput()
Output to the default debug.log
|
static void |
setOutput(java.io.PrintStream p)
Output to the given Stream
|
static void |
setOutput(java.lang.String filename)
Output to the given file
|
static void |
setProperties(java.util.Properties prop)
Set properties to configure debugging.
|
static void |
setThrowableTraces(boolean ttrace)
Enable or disable stack traces in Debuging throwables.
|
static void |
setTiming(boolean timing)
Enable or disable timing in Debug messages.
|
public static final int CRIT
public static final int ERR
public static final int WARN
public static final int INFO
public static final int DEBUG
public static final int VERBOSE
public static final boolean debug
public static java.io.PrintStream debugout
public static void setProperties(java.util.Properties prop)
cx.ath.matthew.io.TeeOutputStream = INFO cx.ath.matthew.io.DOMPrinter = DEBUGThe debug level can be one of CRIT, ERR, WARN, INFO, DEBUG or VERBOSE which correspond to all messages up to that level. The special words YES, ALL and TRUE cause all messages to be printed regardless of level. All other terms disable messages for that class. CRIT and ERR messages are always printed if debugging is enabled unless explicitly disabled. The special class name ALL can be used to set the default level for all classes.
prop
- Properties object to use.public static void loadConfig(java.io.File f) throws java.io.IOException
<class> = <debuglevel>E.G.
cx.ath.matthew.io.TeeOutputStream = INFO cx.ath.matthew.io.DOMPrinter = DEBUGThe debug level can be one of CRIT, ERR, WARN, INFO, DEBUG or VERBOSE which correspond to all messages up to that level. The special words YES, ALL and TRUE cause all messages to be printed regardless of level. All other terms disable messages for that class. CRIT and ERR messages are always printed if debugging is enabled unless explicitly disabled. The special class name ALL can be used to set the default level for all classes.
f
- File to read from.java.io.IOException
public static boolean debugging(java.lang.Class c, int loglevel)
public static boolean debugging(java.lang.String s, int loglevel)
public static void setOutput(java.io.PrintStream p) throws java.io.IOException
java.io.IOException
public static void setOutput(java.lang.String filename) throws java.io.IOException
java.io.IOException
public static void setOutput() throws java.io.IOException
java.io.IOException
public static void print(java.lang.Object d)
d
- The object to logpublic static void print(java.lang.Object o, java.lang.Object d)
o
- The object doing the loggingd
- The object to logpublic static void print(java.lang.Object o, int loglevel, java.lang.Object d)
o
- The object doing the loggingloglevel
- The level to log at (DEBUG, WARN, etc)d
- The object to log with d.toString()public static void print(java.lang.Object o, int loglevel, java.lang.String s)
o
- The object doing the loggingloglevel
- The level to log at (DEBUG, WARN, etc)s
- The log messagepublic static void print(java.lang.Object o, int loglevel, java.lang.Throwable t)
o
- The object doing the loggingloglevel
- The level to log at (DEBUG, WARN, etc)t
- The throwable to log with .toString and .printStackTracepublic static void print(java.lang.Class c, int loglevel, java.lang.Throwable t)
c
- The class doing the loggingloglevel
- The level to log at (DEBUG, WARN, etc)t
- The throwable to log with .toString and .printStackTracepublic static void print(int loglevel, java.lang.Throwable t)
loglevel
- The level to log at (DEBUG, WARN, etc)t
- The throwable to log with .toString and .printStackTraceto turn on stack traces.
public static void print(int loglevel, byte[] b)
loglevel
- The level to log at (DEBUG, WARN, etc)b
- The byte array to print.to enable hex dumping.
,
to change how many bytes are printed.
,
to change the formatting width of hex.
public static void print(int loglevel, java.lang.String s)
loglevel
- The level to log at (DEBUG, WARN, etc)s
- The string to log with d.toString()public static void print(java.lang.Class c, int loglevel, java.lang.Object d)
c
- The class doing the loggingloglevel
- The level to log at (DEBUG, WARN, etc)d
- The object to log with d.toString()public static void print(java.lang.Class c, int loglevel, java.lang.String s)
c
- The class doing the loggingloglevel
- The level to log at (DEBUG, WARN, etc)s
- The log messagepublic static void print(int loglevel, java.lang.Object o)
loglevel
- The level to log at (DEBUG, WARN, etc)o
- The object to logpublic static void printMap(java.lang.Object o, int loglevel, java.util.Map m)
o
- The object doing the loggingloglevel
- The level to log at (DEBUG, WARN, etc)m
- The Map to print outpublic static void printMap(java.lang.Class c, int loglevel, java.util.Map m)
c
- The class doing the loggingloglevel
- The level to log at (DEBUG, WARN, etc)m
- The Map to print outpublic static void printMap(java.util.Map m)
m
- The Map to print outpublic static void printMap(int loglevel, java.util.Map m)
loglevel
- The level to log at (DEBUG, WARN, etc)m
- The Map to print outpublic static void setThrowableTraces(boolean ttrace)
public static void setTiming(boolean timing)
public static void setLineNos(boolean lines)
public static void setHexDump(boolean hexdump)
public static void setByteArrayCount(int count)
public static void setByteArrayWidth(int width)
public static void addFilterCommand(java.lang.Class c, Debug.FilterCommand f)