com.sun.jaw.reference.common
Class Debug

java.lang.Object
  |
  +--com.sun.jaw.reference.common.Debug

public class Debug
extends java.lang.Object

This class provides methods for printing debug messages or logging them to a file. It is possible to specify the trace level of the debug messages. All the classes of the Java Dynamic Management Kit use this class for printing debug messages. You can use this class in your own code for printing debug messages for your own classes.

It is possible to specify the trace level in either of the following ways:

The system properties for specifying a trace level are:

PropertyTrace Level
DEBUGAll messages
DEFAULTMessages that are not associated with a predefined trace level
DEBUG_ADPMessages from the adaptors
DEBUG_CMFMessages from the framework
DEBUG_DISCOMessages from the discovery service
DEBUG_EXCPTExceptions
DEBUG_METAMessages from the metadata service
DEBUG_MLETMessages from the m-let service
DEBUG_RELMessages from the relationship service
DEBUG_REPMessages from the repository service
DEBUG_SNMPMessages from the SNMP Manager service
DEBUG_THREADMessages from the Thread Allocator service
DEBUG_TRACEMessages from any class

In addition, the DEBUG_HEAVY property can be set to get additional traces. Setting the DEBUG property will not switch on the heavy printing.

To specify that debug messages are logged to a file, specify the DEBUG_OUTPUT=filename system property.

The setDefault method enables or disables default mode. If default mode is enabled, messages for the selected trace level and messages not associated with a predefined trace level are printed. If default mode is disabled, no messages that are not associated with a predefined trace level are printed. Only messages for the selected trace level are printed. By default, the default mode is disabled.


Field Summary
static int ADP_DEBUG
          Trace level for the adaptors.
static int CMF_DEBUG
          Trace level for the framework.
static int DISCO_DEBUG
          Trace level for the discovery service.
static int EXCPT_DEBUG
          Trace level for exceptions.
static int HEAVY_DEBUG
          Trace level for getting very talkative traces.
static int META_DEBUG
          Trace level for the metadata service.
static int MLET_DEBUG
          Trace level for the m-let service.
static int NO_DEBUG
          No trace.
static int REL_DEBUG
          Trace level for relationship service.
static int REP_DEBUG
          Trace level for the repository service.
static int SNMP_DEBUG
          Trace level for the Snmp Manager service.
static int THREAD_DEBUG
          Trace level for the thread allocator service.
static int TRACE_DEBUG
          Trace level for any class.
 
Constructor Summary
Debug()
           
 
Method Summary
static void flush()
          Flushes the trace stream.
static int getLevel()
          Gets the currently selected trace levels.
static java.io.PrintWriter getLog()
          Gets the current log used for logging debug messages.
static boolean isLevelSet(int atLevel)
          Check if atLevel is set.
static void parseDebugProperties()
          Parses the system properties specified at the command-line to determine the specified trace level.
static void print(boolean condition, java.lang.Object arg)
          Traces an object according a condition.
static void print(int atLevel, java.lang.Object arg)
          Traces an object with a specific trace level.
static void print(java.lang.Object arg)
          Traces an object.
static void printException(java.lang.Exception e)
          Traces an exception.
static void printFormatted(java.lang.Object arg)
          Write a message on the printer stream associated with the Debug object.
static void println(boolean condition, java.lang.Object arg)
          Traces an object according a condition and appends a carriage return.
static void println(int atLevel, java.lang.Object arg)
          Traces an object with a specific level and appends a carriage return.
static void println(java.lang.Object arg)
          Traces an object and appends a carriage return.
static void setDefault(boolean mode)
          Enables or disables default mode.
static void setLevel(int l)
          Sets the trace level.
static void setLog(java.io.PrintWriter l)
          Sets the log for debug messages.
static void setOff(int forLevel)
          Deactivates a specific trace level.
static void setOffAll()
          Deactivates all trace levels, so that no debug messages will be printed.
static void setOn(int forLevel)
          Activates a specific trace level.
static void setOnAll()
          Activates all trace levels, so that debug messages for all traces will be printed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_DEBUG

public static final int NO_DEBUG
No trace.

CMF_DEBUG

public static final int CMF_DEBUG
Trace level for the framework. Corresponds to the DEBUG_CMF system property.

ADP_DEBUG

public static final int ADP_DEBUG
Trace level for the adaptors. Corresponds to the DEBUG_ADP system property.

REP_DEBUG

public static final int REP_DEBUG
Trace level for the repository service. Corresponds to the DEBUG_REPO system property.

EXCPT_DEBUG

public static final int EXCPT_DEBUG
Trace level for exceptions. Corresponds to the DEBUG_EXCPT system property.

META_DEBUG

public static final int META_DEBUG
Trace level for the metadata service. Corresponds to the DEBUG_META system property.

TRACE_DEBUG

public static final int TRACE_DEBUG
Trace level for any class. Use to distinguish between messages from classes the Java Dynamic Management Kit and other classes.

REL_DEBUG

public static final int REL_DEBUG
Trace level for relationship service. Corresponds to the DEBUG_RELA system property.

MLET_DEBUG

public static final int MLET_DEBUG
Trace level for the m-let service. Corresponds to the DEBUG_MLET system property.

DISCO_DEBUG

public static final int DISCO_DEBUG
Trace level for the discovery service. Corresponds to the DEBUG_DISCO system property.

SNMP_DEBUG

public static final int SNMP_DEBUG
Trace level for the Snmp Manager service. Corresponds to the DEBUG_SNMP system property.

HEAVY_DEBUG

public static final int HEAVY_DEBUG
Trace level for getting very talkative traces. DEBUG_HEAVY system property.

THREAD_DEBUG

public static final int THREAD_DEBUG
Trace level for the thread allocator service. Corresponds to the DEBUG_THREAD system property.
Constructor Detail

Debug

public Debug()
Method Detail

printFormatted

public static void printFormatted(java.lang.Object arg)
Write a message on the printer stream associated with the Debug object. If the stream is null, the method will use System.err The method will pritn the object regardless the setting of the trace level.

flush

public static void flush()
Flushes the trace stream.

print

public static void print(java.lang.Object arg)
Traces an object. If the default mode is disabled, nothing is printed.

print

public static void print(int atLevel,
                         java.lang.Object arg)
Traces an object with a specific trace level. If the specified trace level is not activated, nothing is printed.

print

public static void print(boolean condition,
                         java.lang.Object arg)
Traces an object according a condition. If condition is true and the default mode is enabled, the object is printed on the trace stream.

println

public static void println(java.lang.Object arg)
Traces an object and appends a carriage return. If the default mode is disabled nothing is printed.

println

public static void println(int atLevel,
                           java.lang.Object arg)
Traces an object with a specific level and appends a carriage return. If the specified trace level is not activated, nothing is printed.

println

public static void println(boolean condition,
                           java.lang.Object arg)
Traces an object according a condition and appends a carriage return. If condition is true and the default mode is enabled, the object is printed on the trace stream.

printException

public static void printException(java.lang.Exception e)
Traces an exception. If the trace level EXCPT_DEBUG is not activated, nothing is printed.

parseDebugProperties

public static void parseDebugProperties()
Parses the system properties specified at the command-line to determine the specified trace level.

isLevelSet

public static boolean isLevelSet(int atLevel)
Check if atLevel is set.

getLevel

public static int getLevel()
Gets the currently selected trace levels. They are expressed as a bit map (by ORing the different trace levels defined by the class).
Returns:
The currently selected trace levels.

getLog

public static java.io.PrintWriter getLog()
Gets the current log used for logging debug messages.
Returns:
The current PrintWriter stream used for logging debug messages.

setOnAll

public static void setOnAll()
Activates all trace levels, so that debug messages for all traces will be printed.

setOn

public static void setOn(int forLevel)
Activates a specific trace level.
Parameters:
forLevel - The trace level to be activated.

setOffAll

public static void setOffAll()
Deactivates all trace levels, so that no debug messages will be printed.

setOff

public static void setOff(int forLevel)
Deactivates a specific trace level.
Parameters:
forLevel - The trace level to be deactivated.

setLevel

public static void setLevel(int l)
Sets the trace level.
Parameters:
l - The new trace level.

setDefault

public static void setDefault(boolean mode)
Enables or disables default mode. If default mode is enabled, messages for the selected trace level and messages not associated with a predefined trace level are printed. If default mode is disabled, no messages that are not associated with a predefined trace level are printed. Only messages for the selected trace level are printed.

By default, the default mode is disabled.

Parameters:
mode - true to enable default mode or false to disable default mode.

setLog

public static void setLog(java.io.PrintWriter l)
Sets the log for debug messages. By default debug messages are printed to the standard error stream. If a null reference is passed to this method, the standard error stream is used.
Parameters:
l - The PrintWriter stream to be used for logging debug messages.