org.jlog2
Class LoggerHandler

java.lang.Object
  extended by org.jlog2.LoggerHandler

public class LoggerHandler
extends java.lang.Object

This class handles logging operations.


Field Summary
static java.lang.String ALL
          Indicates all logging levels
static java.lang.String ERROR
          The error log level
static java.lang.String INFO
          The info log level
protected static LoggerFactory loggerFactory
          The factory that generates the loggers
static java.lang.String MESSAGE
          The message log level - always output to stdout and any others
static java.lang.String SEVERE
          The severe log level
static java.lang.Object syncOn
          An object to synchronize on
static java.lang.String WARN
          The warn log level
 
Constructor Summary
LoggerHandler()
          Creates a new instance of LoggerHandler.
LoggerHandler(LoggerFactory theLoggerFactory)
          Creates a new instance of LoggerHandler.
 
Method Summary
static void addDefaultDebugChannels(java.util.Vector theLogChannels)
          Add default channels to write the debug messages to.
static void addDefaultLogChannels(java.util.Vector theLogChannels)
          Add default channels to write the log messages to.
static void debugError(Logger logger, java.lang.String level, java.lang.Exception error)
          Log the error on the debug log stream.
static void debugMessage(Logger logger, java.lang.String level, java.lang.String methodName, java.lang.String message)
          Log the message on the debug stream if suitable.
static Logger getLogger(java.lang.String loggerID)
          Return a logger appropriate to the class specified.
static boolean levelOK(java.lang.String theLevel, java.lang.String logLevel)
          Return true if the level to log at is higher or equal to the configuration level.
static void logError(Logger logger, java.lang.String level, java.lang.Exception error)
          Log the error on the log stream.
static void logMessage(Logger logger, java.lang.String level, java.lang.String methodName, java.lang.String message)
          Log the message on the logger if suitable.
static void setUserLoggerFactory(LoggerFactory userLoggerFactory)
          Set the user logger factory to control the logging channels.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ALL

public static final java.lang.String ALL
Indicates all logging levels

See Also:
Constant Field Values

INFO

public static final java.lang.String INFO
The info log level

See Also:
Constant Field Values

WARN

public static final java.lang.String WARN
The warn log level

See Also:
Constant Field Values

ERROR

public static final java.lang.String ERROR
The error log level

See Also:
Constant Field Values

SEVERE

public static final java.lang.String SEVERE
The severe log level

See Also:
Constant Field Values

MESSAGE

public static final java.lang.String MESSAGE
The message log level - always output to stdout and any others

See Also:
Constant Field Values

syncOn

public static final java.lang.Object syncOn
An object to synchronize on


loggerFactory

protected static LoggerFactory loggerFactory
The factory that generates the loggers

Constructor Detail

LoggerHandler

public LoggerHandler()
              throws java.lang.Exception
Creates a new instance of LoggerHandler.

Throws:
java.lang.Exception - any error.

LoggerHandler

public LoggerHandler(LoggerFactory theLoggerFactory)
              throws java.lang.Exception
Creates a new instance of LoggerHandler.

Parameters:
theLoggerFactory - this can be a new logger factory you have written to override the operation of the default CustomLoggerFactory.
Throws:
java.lang.Exception - any error.
Method Detail

setUserLoggerFactory

public static void setUserLoggerFactory(LoggerFactory userLoggerFactory)
Set the user logger factory to control the logging channels.

Parameters:
userLoggerFactory - the factory to generate new loggers with.

getLogger

public static Logger getLogger(java.lang.String loggerID)
Return a logger appropriate to the class specified.

Parameters:
loggerID - the id used to identify the logger.
Returns:
the global logger by default in this implementation.

addDefaultLogChannels

public static void addDefaultLogChannels(java.util.Vector theLogChannels)
Add default channels to write the log messages to.

Parameters:
theLogChannels - the channels to write the log messages to.

addDefaultDebugChannels

public static void addDefaultDebugChannels(java.util.Vector theLogChannels)
Add default channels to write the debug messages to.

Parameters:
theLogChannels - the channels to write the debug messages to.

levelOK

public static boolean levelOK(java.lang.String theLevel,
                              java.lang.String logLevel)
Return true if the level to log at is higher or equal to the configuration level.

Parameters:
theLevel - the level the error or log message is at.
logLevel - the level the configuration is set to log to.
Returns:
true if theLevel is higher or equal to logLevel.

logMessage

public static void logMessage(Logger logger,
                              java.lang.String level,
                              java.lang.String methodName,
                              java.lang.String message)
Log the message on the logger if suitable.

Parameters:
logger - the logger to write to.
level - the error level.
methodName - the name of the method in the class throwing the exception.
message - the message to log.

debugMessage

public static void debugMessage(Logger logger,
                                java.lang.String level,
                                java.lang.String methodName,
                                java.lang.String message)
Log the message on the debug stream if suitable.

Parameters:
logger - the logger to write to.
level - the error level.
methodName - the name of the method in the class throwing the exception.
message - the message to log.

logError

public static void logError(Logger logger,
                            java.lang.String level,
                            java.lang.Exception error)
Log the error on the log stream.

Parameters:
logger - the logger to write to.
level - the error level.
error - the error to log.

debugError

public static void debugError(Logger logger,
                              java.lang.String level,
                              java.lang.Exception error)
Log the error on the debug log stream.

Parameters:
logger - the logger to write to.
level - the error level.
error - the error to log.