All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.sgi.sysadm.util.Log

java.lang.Object
   |
   +----com.sgi.sysadm.util.Log

public final class Log
extends Object
The Log class provides debugging and assertion support. Debug messages may be sent at one of several different levels. A fine level of control over which debugging messages to display is provided via two features. First, there are several methods for logging messages according to the type of message. Second, each non-terminating logging method takes a module name as its first argument. A module in this context is simply a String identifying a logically related set of code. It is arbitrarily determined by the programmer and is typically a class name or related group of classes.

To control the messages printed, you can set the debugging levels (levels correspond to the logging methods) from the SystemProperties. The Property used is Log.debugLevel. The recognized values are:

All of the above option letters and strings are case insensitive.

For example java -DLog.debugLevel=ALL test will turn on all logging, while java -DLog.debugLevel=WE test will turn on warnings and errors. If the property Log.debugLevel is not set, Log defaults to displaying messages of type Assert, Fatal, and Error.

After the level indication there may optionally follow a list of modules. By default messages from all modules are displayed. If one or more modules are specified, the output is restricted to only messages from those modules.

The modules specification is a colon followed by a comma-separated list of modules. For example java -DLog.debugLevel=ALL:alpha,beta test displays messages of any level from only the alpha and beta modules.


Variable Index

 o ASSERT
Used with leveOn()/levelOff() to enable/disable display of messages from the assert() logging method.
 o DEBUG
Used with leveOn()/levelOff() to enable/disable display of messages from the debug() logging method.
 o ERROR
Used with leveOn()/levelOff() to enable/disable display of messages from the error() logging method.
 o INFO
Used with leveOn()/levelOff() to enable/disable display of messages from the info() logging method.
 o TRACE
Used with leveOn()/levelOff() to enable/disable display of messages from the trace(), traceIn(), and traceOut() logging methods.
 o WARNING
Used with leveOn()/levelOff() to enable/disable display of messages from the warning() logging method.

Method Index

 o addModule(String)
Add a module to the set of modules to display.
 o assert(boolean, String)
Verify some condition is true; if not log a message and terminate the program.
 o debug(String, String)
Log a debug level message.
 o error(String, String)
Log an error message.
 o fatal(String)
Log a message and terminate the program.
 o info(String, String)
Log an informational level message.
 o isLevelOn(int)
Returns a boolean that tells if a certain debug level is turned on.
 o levelOff(int)
Disable display of a logging level.
 o levelOn(int)
Enable display of a logging level.
 o removeModule(String)
Remove a module from the set of modules to display.
 o trace(String, String)
Log a tracing message.
 o traceIn(String, String)
Log a method entry message.
 o traceOut(String, String)
Log a method exit message.
 o warning(String, String)
Log a warning message.

Variables

 o TRACE
 public static final int TRACE
Used with leveOn()/levelOff() to enable/disable display of messages from the trace(), traceIn(), and traceOut() logging methods.

 o DEBUG
 public static final int DEBUG
Used with leveOn()/levelOff() to enable/disable display of messages from the debug() logging method.

 o INFO
 public static final int INFO
Used with leveOn()/levelOff() to enable/disable display of messages from the info() logging method.

 o WARNING
 public static final int WARNING
Used with leveOn()/levelOff() to enable/disable display of messages from the warning() logging method.

 o ERROR
 public static final int ERROR
Used with leveOn()/levelOff() to enable/disable display of messages from the error() logging method.

 o ASSERT
 public static final int ASSERT
Used with leveOn()/levelOff() to enable/disable display of messages from the assert() logging method.

Methods

 o isLevelOn
 public static boolean isLevelOn(int level)
Returns a boolean that tells if a certain debug level is turned on. This can be useful so that client code can avoid creating expensive debug messages if that level isn't on.

Parameters:
level - The level the client is interested in (e.g Log.DEBUG)
Returns:
Whether that level is on or not.
 o addModule
 public static void addModule(String module)
Add a module to the set of modules to display.

Parameters:
module - the module name to add
 o removeModule
 public static void removeModule(String module)
Remove a module from the set of modules to display.

Parameters:
module - the module name to remove
 o levelOn
 public static void levelOn(int level)
Enable display of a logging level.

Parameters:
level - the level to enable
 o levelOff
 public static void levelOff(int level)
Disable display of a logging level.

Parameters:
level - the level to disable
 o trace
 public static void trace(String module,
                          String msg)
Log a tracing message.

Parameters:
module - the module the message is from
msg - the message to log
 o traceIn
 public static void traceIn(String module,
                            String msg)
Log a method entry message.

Parameters:
module - the module the message is from
msg - the message to log. Should be the method name, and may also include other information such as parameters.
 o traceOut
 public static void traceOut(String module,
                             String msg)
Log a method exit message.

Parameters:
module - the module the message is from
msg - the message to log. Should be the method name, and may also include other information.
 o debug
 public static void debug(String module,
                          String msg)
Log a debug level message.

Parameters:
module - the module the message is from
msg - the message to log
 o info
 public static void info(String module,
                         String msg)
Log an informational level message.

Parameters:
module - the module the message is from
msg - the message to log
 o warning
 public static void warning(String module,
                            String msg)
Log a warning message.

Parameters:
module - the module the message is from
msg - the message to log
 o error
 public static void error(String module,
                          String msg)
Log an error message.

Parameters:
module - the module the message is from
msg - the message to log
 o fatal
 public static void fatal(String msg)
Log a message and terminate the program. The message will be logged, a stack dump generated, and then HostContext.abort will be called.

Parameters:
msg - the message to log
See Also:
abort
 o assert
 public static void assert(boolean cond,
                           String msg)
Verify some condition is true; if not log a message and terminate the program. If the boolean condition is false (and the ASSERT level is enabled) the message will be logged, a stack dump generated, and then HostContext.abort will be called.

Parameters:
cond - a condition which is expected to always be true
msg - the message to log

All Packages  Class Hierarchy  This Package  Previous  Next  Index