abbot
Class Log

java.lang.Object
  extended byabbot.Log

public final class Log
extends Object

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:

Per-class stack trace depth can be specified when adding a class, e.g. classname[:stack-depth].

Version:
$Revision: 1.24 $
Author:
twall

Field Summary
static boolean DEBUG_BUILD
          Global final to determine whether debugging code is generated.
static boolean expectDebugOutput
          Whether any debugging output is enabled.
static int FULL_STACK
          Mnemonic to print all lines of a stack trace.
(package private) static PrintStream systemErr
           
(package private) static PrintStream systemOut
           
 
Method Summary
static void addDebugClass(Class c)
          Indicate the class to add to debug output.
static void addDebugClass(Class c, int depth)
          Indicate that debug messages should be output for the given class.
static void addDebugClass(String id)
          Indicate the class name[:depth] to add to debug output.
static void assertNotSwing()
          Assert that the current thread is NOT the swing thread.
static void assertSwing()
          Assert that the current thread is the swing thread.
static void assertTrue(boolean test)
          Basic assertion.
static void assertTrue(String desc, boolean test)
          Standard assert, with a message provided since java can't easily stringify a boolean expression.
static void close()
           
static void debug()
          Print an empty debug message.
static void debug(Class c, String event)
          Use this version for performance-critical/high traffic areas
static void debug(Object obj)
          Print a debug message using the object given stringified as the message.
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(Throwable thr)
          Similar to warn(Throwable).
static void enableLogging(String filename)
          Enable log output to the given file.
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 thrown)
           
static String[] init(String[] args)
          Debug/log initialization, presumably from the command line.
static boolean isClassDebugEnabled(Class c)
           
static void log(String message)
          Log a message.
static void log(String message, Throwable thr)
           
static void log(Throwable thr)
          Log an exception.
static boolean loggingEnabled()
          Is log output enabled?
static void removeDebugClass(Class c)
          Indicate that the given class should NOT be debugged (assuming --debug all)
static void removeDebugClass(String id)
          Indicate the class name to exclude from debug output.
static void setDebugStackDepth(int depth)
          Sets the debug stack depth to the given amount
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(Throwable thr)
          Issue a programmer warning, which will include the source line of the original thrown object.
static void warnIfNotSwing()
          print warning if not invoked on Swing thread
static void warnIfNotSwing(int lines)
          print warning if not invoked on Swing thread, with given number of lines of stack trace.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG_BUILD

public static final boolean DEBUG_BUILD
Global final to determine whether debugging code is generated. This should be changed to false to build production code.

See Also:
Constant Field Values

FULL_STACK

public static final int FULL_STACK
Mnemonic to print all lines of a stack trace.

See Also:
Constant Field Values

expectDebugOutput

public static boolean expectDebugOutput
Whether any debugging output is enabled.


systemOut

static PrintStream systemOut

systemErr

static PrintStream systemErr
Method Detail

init

public static String[] init(String[] args)
Debug/log initialization, presumably from the command line.
Recognized options:
        --debug all | className[:depth] | *.partialClassName[:depth]
        --no-debug className | *.partialClassName
        --log 
        --no-timestamp
        --enable-warnings
        --show-threads
        --stack-depth 
        --exception-depth 
        


loggingEnabled

public static boolean loggingEnabled()
Is log output enabled?


enableLogging

public static void enableLogging(String filename)
Enable log output to the given file. If the filename given is "-", stdout is used instead of a file.


setDebugStackDepth

public static void setDebugStackDepth(int depth)
Sets the debug stack depth to the given amount


removeDebugClass

public static void removeDebugClass(String id)
Indicate the class name to exclude from debug output.


removeDebugClass

public static void removeDebugClass(Class c)
Indicate that the given class should NOT be debugged (assuming --debug all)


addDebugClass

public static void addDebugClass(String id)
Indicate the class name[:depth] to add to debug output.


addDebugClass

public static void addDebugClass(Class c)
Indicate the class to add to debug output.


addDebugClass

public static void addDebugClass(Class c,
                                 int depth)
Indicate that debug messages should be output for the given class.


isClassDebugEnabled

public static boolean isClassDebugEnabled(Class c)

debug

public static void debug(Class c,
                         String event)
Use this version for performance-critical/high traffic areas


debug

public static void debug(String event)
Print a debug message.


debug

public static void debug(String event,
                         int lines)
Print a debug message with the given number of stack lines.


debug

public static void debug()
Print an empty debug message.


debug

public static void debug(Throwable thr)
Similar to warn(Throwable).


debug

public static void debug(Object obj)
Print a debug message using the object given stringified as the message.


getStack

public static String getStack(int lines)
Retrieve the given number of lines of the current stack, as a string.


getStack

public static String getStack(int lines,
                              Throwable thr)
Retrieve the given number of lines of stack from the given Throwable, as a string.


getStack

public static String getStack(Throwable thrown)

warn

public static void warn(String message)
Issue a programmer warning, which will include the source line of the warning.


warn

public 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.


warn

public static void warn(Throwable thr)
Issue a programmer warning, which will include the source line of the original thrown object.


assertTrue

public static void assertTrue(String desc,
                              boolean test)
Standard assert, with a message provided since java can't easily stringify a boolean expression.


assertTrue

public static void assertTrue(boolean test)
Basic assertion. Not very useful without a description, though.


assertSwing

public static void assertSwing()
Assert that the current thread is the swing thread.


warnIfNotSwing

public static void warnIfNotSwing(int lines)
print warning if not invoked on Swing thread, with given number of lines of stack trace.


warnIfNotSwing

public static void warnIfNotSwing()
print warning if not invoked on Swing thread


assertNotSwing

public static void assertNotSwing()
Assert that the current thread is NOT the swing thread.


log

public static void log(Throwable thr)
Log an exception.


log

public static void log(String message,
                       Throwable thr)

log

public static void log(String message)
Log a message.


close

public static void close()


Copyright © 2002-2004 Timothy Wall. All Rights Reserved.
Abbot is hosted on

SourceForge