|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbcds.tools.DL
public class DL
Provides a very simplistic logger for "debug". Logging can be controlled through two environment variables:
If the value given is not an integer or is out or range, a warning is written to System.err and logging is disabled. If DL_Level does not exist in the program environment, logging is disabled.
By defult, logs are written to System.err. If the given file cannot be opened, a warning is written to System.err and all logs go there as well.
Code examples:
How to use:
$ DL_Level=0 java myprogram - Output goes to stderr. Everything is logged. $ DL_Level=0 DL_File=/tmp/err.log java myprogram - Output goes to /tmp/err.log, which is overwritten every time the program is executed. Everything is logged. $ DL_Level=0 DL_File=+/tmp/err.log java myprogram - Same as before, but now the log messages are appended to the file.
Note: The desired level of logging and the destination file cannot be changed after program initialization (they remain constant throughout the program execution). Also, all methods and variables are static, so that effectively only one instance per application will ever exist. In fact, instantiation is disabled.
Method Summary | |
---|---|
static byte |
getLevel()
Returns the current minimum logging level. |
static boolean |
isEnabled()
Returns true if the current logging level is less than Integer.MAX_VALUE. |
static void |
log(byte n,
java.lang.String msg)
Logs a message n is at least equal to the current logging
level. |
static void |
log(byte n,
java.lang.String fmt,
java.lang.Object... args)
Logs a formatted message n is at least equal to the
current logging level. |
static void |
log(java.lang.String msg)
Logs a message if isEnabled() is true; otherwise the message is discarded. |
static void |
log(java.lang.String fmt,
java.lang.Object... args)
Logs a formatted string using Locale.US as the locale. |
static void |
main(java.lang.String[] args)
|
static void |
setLevel(byte n)
Sets the minimum logging level. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static void setLevel(byte n)
n
are discarded.
public static byte getLevel()
public static boolean isEnabled()
public static void log(java.lang.String msg)
public static void log(java.lang.String fmt, java.lang.Object... args)
public static void log(byte n, java.lang.String msg)
n
is at least equal to the current logging
level.
public static void log(byte n, java.lang.String fmt, java.lang.Object... args)
n
is at least equal to the
current logging level.
public static void main(java.lang.String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |