org.openrdf.util.log
Class ThreadLog

java.lang.Object
  extended byorg.openrdf.util.log.ThreadLog

public class ThreadLog
extends Object

Thread-based logging utility. The ThreadLog requires threads to register themselves with the ThreadLog. In this registration procedure, a mapping is made between the thread calling the registration method and an instance of ThreadLog. This mapping is later used in all calls to logging-methods to look-up whether these messages should be logged, and where they should be logged.

Log messages are assigned a "level of importance". From high to low, these levels are ERROR, WARNING, STATUS and TRACE. Messages can be suppressed based on these levels. If a Thread registers itself with log level WARNING, only errors and warning will be logged; status messages and traces will be suppressed.


Field Summary
static int ALL
           
static int ERROR
           
static int NONE
           
static int STATUS
           
static int TRACE
           
static int WARNING
           
 
Method Summary
static void deregisterThread()
          Deregisters the calling thread with the ThreadLog.
static void error(String msg)
          Logs an error.
static void error(String msg, Object arg)
          Logs an error.
static void log(String msg)
          Logs a message.
static void log(String msg, Object arg)
          Logs a message.
static void registerThread(String logFile, int logLevel)
          Registers the calling thread with the ThreadLog.
static void setDefaultLog(String logFile, int logLevel)
          Sets a default log file for all threads that have not registered themselves.
static void setLogLevel(int logLevel)
          Changes the log level for the calling thread.
static void trace(String msg)
          Logs a trace message.
static void trace(String msg, Object arg)
          Logs a trace message.
static void unsetDefaultLog()
          Unsets the default log file for all threads that have not registered themselves.
static void warning(String msg)
          Logs a warning.
static void warning(String msg, Object arg)
          Logs a warning.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NONE

public static final int NONE
See Also:
Constant Field Values

ERROR

public static final int ERROR
See Also:
Constant Field Values

WARNING

public static final int WARNING
See Also:
Constant Field Values

STATUS

public static final int STATUS
See Also:
Constant Field Values

TRACE

public static final int TRACE
See Also:
Constant Field Values

ALL

public static final int ALL
See Also:
Constant Field Values
Method Detail

setDefaultLog

public static void setDefaultLog(String logFile,
                                 int logLevel)
Sets a default log file for all threads that have not registered themselves. Logging calls from any of these threads to ThreadLog will be logged to the specified log file if their priority is equal to or higher then the specified log level. If 'logFile' is equal to 'null', messages will be printed to System.err.

Parameters:
logFile - The file to log to, or null to log messages to System.err.
logLevel - One of the constants ERROR, WARNING, STATUS, TRACE, or ALL.
See Also:
ERROR, WARNING, STATUS, TRACE, ALL

unsetDefaultLog

public static void unsetDefaultLog()
Unsets the default log file for all threads that have not registered themselves.


registerThread

public static void registerThread(String logFile,
                                  int logLevel)
Registers the calling thread with the ThreadLog. Logging calls to ThreadLog will be logged to the specified log file if their priority is equal to or higher then the specified log level. If 'logFile' is equal to 'null', messages will be printed to System.err.

Parameters:
logFile - The file to log to, or null to log messages to System.err.
logLevel - One of the constants ERROR, WARNING, STATUS, TRACE, or ALL.
See Also:
ERROR, WARNING, STATUS, TRACE, ALL

setLogLevel

public static void setLogLevel(int logLevel)
Changes the log level for the calling thread.

Parameters:
logLevel - One of the constants ERROR, WARNING, STATUS, TRACE, or ALL.
See Also:
ERROR, WARNING, STATUS, TRACE

deregisterThread

public static void deregisterThread()
Deregisters the calling thread with the ThreadLog. Logging calls to ThreadLog on the calling thread will no longer be logged.


error

public static void error(String msg)
Logs an error.

Parameters:
msg - A indicative message for the error.

error

public static void error(String msg,
                         Object arg)
Logs an error.

Parameters:
msg - A indicative message for the error.
arg - An argument related to the error. In case arg is an instance of java.lang.Throwable, the message and stack trace of the argument will be logged.

warning

public static void warning(String msg)
Logs a warning.

Parameters:
msg - A indicative message for the warning.

warning

public static void warning(String msg,
                           Object arg)
Logs a warning.

Parameters:
msg - A indicative message for the warning.
arg - An argument related to the warning. In case arg is an instance of java.lang.Throwable, the message and stack trace of the argument will be logged.

log

public static void log(String msg)
Logs a message.

Parameters:
msg - A indicative message for the message.

log

public static void log(String msg,
                       Object arg)
Logs a message.

Parameters:
msg - A indicative message for the message.
arg - An argument related to the message. In case arg is an instance of java.lang.Throwable, the message and stack trace of the argument will be logged.

trace

public static void trace(String msg)
Logs a trace message.

Parameters:
msg - A indicative message for the trace message.

trace

public static void trace(String msg,
                         Object arg)
Logs a trace message.

Parameters:
msg - A indicative message for the trace message.
arg - An argument related to the trace message. In case arg is an instance of java.lang.Throwable, the message and stack trace of the argument will be logged.


Copyright © 2002-2006 Aduna BV, GNU LGPL License applies.