|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object abbot.Log
public class Log
Various logging, assertion, and debug routines. Typical usage is to include the following code
public static void main(String[] args) {
args = Log.init
(args)
...
}
at an application's main entry point. This way the Log class can remove its
options from the full set passed into the application. See the
Log.init
method for initialization options. General usage notes on public functions:
warn(String)
log(String)
debug(String)
Per-class stack trace depth can be specified when adding a class, e.g. classname[:stack-depth].
Extraction of the stack trace and logging to file are performed on a
separate thread to minimize performance impact due to filesystem delays.
Use setSynchronous(false)
if you want
the output to be asynchronous with program execution.
Field Summary | |
---|---|
static int |
FULL_STACK
Mnemonic to print all lines of a stack trace. |
static int |
NO_STACK
No stack, just a message. |
Constructor Summary | |
---|---|
protected |
Log()
No instantiations. |
Method Summary | |
---|---|
static void |
addDebugClass(Class class1)
Indicate that debug messages should be output for the given class. |
static void |
addDebugClass(String className)
Indicate the class name[:depth] to add to debug output. |
static void |
addDebugClass(String className,
int depth)
Indicate that debug messages should be output for the given class. |
static void |
clearDebugClasses()
Resets the lists of classes to debug and not debug to be empty, and turns debugAll off. |
static void |
close()
|
static void |
debug(String event)
Print a debug message. |
static void |
debug(String event,
int lines)
Print a debug message with the given number of stack lines. |
static void |
debug(String m,
Throwable e)
Issue a debug statement regarding the given Throwable . |
static void |
debug(Throwable thr)
Use this to display debug output for expected or common exceptions. |
(package private) static void |
flush()
|
(package private) static int |
getClassStackDepth(String cname)
|
static String |
getHostName()
|
static PrintStream |
getLog()
|
static String |
getLogFilename()
|
static String |
getStack(int lines)
Retrieve the given number of lines of the current stack, as a string. |
static String |
getStack(int lines,
Throwable thr)
Retrieve the given number of lines of stack from the given Throwable, as a string. |
static String |
getStack(Throwable t)
Retrieve the full stack from the given Throwable, as a string. |
static String |
getSystemInfo()
|
static String[] |
init(String[] args)
Debug/log initialization, presumably from the command line. |
static void |
initLogging(String filename)
Enable log output to the given file. |
static boolean |
isClassDebugEnabled(Class cls)
|
static boolean |
isClassDebugEnabled(String className)
|
static void |
log(String message)
Log a message. |
static void |
log(String message,
Throwable thr)
Log an exception with a description. |
static void |
log(Throwable thr)
Log an exception. |
static boolean |
loggingInitialized()
Is log output enabled? |
static void |
removeDebugClass(Class class1)
Indicate that debug messages should no longer be output for the given class. |
static void |
removeDebugClass(String className)
Indicate that the given class should NOT be debugged (assuming --debug all) |
static void |
setDebugStackDepth(int depth)
Sets the debug stack depth to the given amount |
static void |
setDestination(PrintStream ps)
Enable log output to the given PrintStream . |
static void |
setEchoToConsole(boolean b)
Set whether messages are echoed to the console in addition to the log. |
static void |
setShowThreads(boolean b)
Set whether to display the current thread of execution. |
static void |
setSynchronous(boolean b)
Set whether log output is synchronous with program execution. |
static void |
warn(String message)
Issue a programmer warning, which will include the source line of the warning. |
static void |
warn(String message,
int lines)
Issue a programmer warning, which will include the source line of the warning, and a stack trace with up to the given number of lines. |
static void |
warn(String message,
Throwable e)
Issue a programmer warning, which will include the source line of the warning. |
static void |
warn(Throwable thr)
Issue a programmer warning, which will include the source line of the original thrown object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int FULL_STACK
public static final int NO_STACK
Constructor Detail |
---|
protected Log()
Method Detail |
---|
public static String[] init(String[] args)
--debug all | className[:depth] | *.partialClassName[:depth] --no-debug className | *.partialClassName --log--no-timestamp --enable-warnings --show-threads --stack-depth --exception-depth
public static boolean loggingInitialized()
public static String getHostName()
public static String getLogFilename()
public static PrintStream getLog()
public static void initLogging(String filename)
public static void setDestination(PrintStream ps)
PrintStream
.
public static String getSystemInfo()
public static void setDebugStackDepth(int depth)
public static void clearDebugClasses()
public static void removeDebugClass(String className)
public static void addDebugClass(Class class1)
public static void removeDebugClass(Class class1)
public static void addDebugClass(String className)
public static void addDebugClass(String className, int depth)
public static boolean isClassDebugEnabled(Class cls)
public static boolean isClassDebugEnabled(String className)
static int getClassStackDepth(String cname)
public static void debug(String event)
public static void debug(String event, int lines)
public static void debug(Throwable thr)
public static void debug(String m, Throwable e)
Throwable
.
public static String getStack(int lines)
public static String getStack(Throwable t)
public static String getStack(int lines, Throwable thr)
public static void warn(String message)
public static void warn(String message, Throwable e)
public static void warn(String message, int lines)
public static void warn(Throwable thr)
public static void log(Throwable thr)
public static void log(String message, Throwable thr)
public static void log(String message)
static void flush()
public static void close()
public static void setSynchronous(boolean b)
public static void setShowThreads(boolean b)
public static void setEchoToConsole(boolean b)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |