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: Enable all levels
- NONE: Disable all levels (except for FATAL)
- Any combination of
- T (Trace)
- D (Debug)
- I (Info)
- W (Warning)
- E (Error)
- A (Assert)
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.
-
ASSERT
- Used with leveOn()/levelOff() to enable/disable display of messages
from the assert() logging method.
-
DEBUG
- Used with leveOn()/levelOff() to enable/disable display of messages
from the debug() logging method.
-
ERROR
- Used with leveOn()/levelOff() to enable/disable display of messages
from the error() logging method.
-
INFO
- Used with leveOn()/levelOff() to enable/disable display of messages
from the info() logging method.
-
TRACE
- Used with leveOn()/levelOff() to enable/disable display of messages
from the trace(), traceIn(), and traceOut() logging methods.
-
WARNING
- Used with leveOn()/levelOff() to enable/disable display of messages
from the warning() logging method.
-
addModule(String)
- Add a module to the set of modules to display.
-
assert(boolean, String)
- Verify some condition is true; if not log a message and terminate
the program.
-
debug(String, String)
- Log a debug level message.
-
error(String, String)
- Log an error message.
-
fatal(String)
- Log a message and terminate the program.
-
info(String, String)
- Log an informational level message.
-
isLevelOn(int)
- Returns a boolean that tells if a certain debug level is turned
on.
-
levelOff(int)
- Disable display of a logging level.
-
levelOn(int)
- Enable display of a logging level.
-
removeModule(String)
- Remove a module from the set of modules to display.
-
trace(String, String)
- Log a tracing message.
-
traceIn(String, String)
- Log a method entry message.
-
traceOut(String, String)
- Log a method exit message.
-
warning(String, String)
- Log a warning message.
TRACE
public static final int TRACE
- Used with leveOn()/levelOff() to enable/disable display of messages
from the trace(), traceIn(), and traceOut() logging methods.
DEBUG
public static final int DEBUG
- Used with leveOn()/levelOff() to enable/disable display of messages
from the debug() logging method.
INFO
public static final int INFO
- Used with leveOn()/levelOff() to enable/disable display of messages
from the info() logging method.
WARNING
public static final int WARNING
- Used with leveOn()/levelOff() to enable/disable display of messages
from the warning() logging method.
ERROR
public static final int ERROR
- Used with leveOn()/levelOff() to enable/disable display of messages
from the error() logging method.
ASSERT
public static final int ASSERT
- Used with leveOn()/levelOff() to enable/disable display of messages
from the assert() logging method.
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.
addModule
public static void addModule(String module)
- Add a module to the set of modules to display.
- Parameters:
- module - the module name to add
removeModule
public static void removeModule(String module)
- Remove a module from the set of modules to display.
- Parameters:
- module - the module name to remove
levelOn
public static void levelOn(int level)
- Enable display of a logging level.
- Parameters:
- level - the level to enable
levelOff
public static void levelOff(int level)
- Disable display of a logging level.
- Parameters:
- level - the level to disable
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
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.
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.
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
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
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
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
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
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