net.sourceforge.nite.util
Class Debug

java.lang.Object
  extended by net.sourceforge.nite.util.Debug

public class Debug
extends java.lang.Object

A simple utility for controlling printed messages. Five levels of information are defined and users can set the PrintStream on which messages are printed. The levels of output are:

Each level prints all the types in lower levels plus its own type of message. The default level is 3.

Author:
Jonathan Kilgour

Field Summary
static int DEBUG
           
static int ERROR
           
static int IMPORTANT
           
static int NO_MESSAGES
           
static int PROGRAMMER
           
static int WARNING
           
 
Constructor Summary
Debug()
           
 
Method Summary
static int getDebugLevel()
          Return true if debugging is on, false otherwise
static java.io.PrintStream getStream()
          Switch the output PrintStream
static boolean isDebugging()
          Return true if debugging is on, false otherwise
static void print(java.lang.String message)
          Print a debug message to the appropriate output stream - this version has no debug level, so we assume it's at WARNING level.
static void print(java.lang.String message, int level)
          Print a debug message to the appropriate output stream - if the level given is at least equal to out current debug level.
static void setDebug(boolean level)
          Switch debugging to default level (WARNINGS) if true or completely off if false
static void setDebug(int level)
          Switch debugging to the given level
static void setStream(java.io.PrintStream str)
          Switch the output PrintStream
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_MESSAGES

public static final int NO_MESSAGES
See Also:
Constant Field Values

ERROR

public static final int ERROR
See Also:
Constant Field Values

IMPORTANT

public static final int IMPORTANT
See Also:
Constant Field Values

WARNING

public static final int WARNING
See Also:
Constant Field Values

DEBUG

public static final int DEBUG
See Also:
Constant Field Values

PROGRAMMER

public static final int PROGRAMMER
See Also:
Constant Field Values
Constructor Detail

Debug

public Debug()
Method Detail

setDebug

public static void setDebug(boolean level)
Switch debugging to default level (WARNINGS) if true or completely off if false


setDebug

public static void setDebug(int level)
Switch debugging to the given level


isDebugging

public static boolean isDebugging()
Return true if debugging is on, false otherwise


getDebugLevel

public static int getDebugLevel()
Return true if debugging is on, false otherwise


setStream

public static void setStream(java.io.PrintStream str)
Switch the output PrintStream


getStream

public static java.io.PrintStream getStream()
Switch the output PrintStream


print

public static void print(java.lang.String message,
                         int level)
Print a debug message to the appropriate output stream - if the level given is at least equal to out current debug level.

Parameters:
message - the debug message.
level - the debug level of this message.

print

public static void print(java.lang.String message)
Print a debug message to the appropriate output stream - this version has no debug level, so we assume it's at WARNING level.

Parameters:
message - the debug message.