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
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.
 
Method Summary
static void addDebugChannel(java.lang.String channelType, LogChannel logChannel)
          Add a new debugging channel.
static void addLogChannel(java.lang.String channelType, LogChannel logChannel)
          Add a new logging channel.
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 java.util.Vector getLogLevels()
          Get a list of all possible logging levels.
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.
 
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

Constructor Detail

LoggerHandler

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

Throws:
java.lang.Exception - any error.
Method Detail

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.

addLogChannel

public static void addLogChannel(java.lang.String channelType,
                                 LogChannel logChannel)
Add a new logging channel.

Parameters:
channelType - the channel type. Can be LogConst.STDOUTID, STDERRID or STDFILEID.
logChannel - the channel to add, of the appropriate type.

addDebugChannel

public static void addDebugChannel(java.lang.String channelType,
                                   LogChannel logChannel)
Add a new debugging channel.

Parameters:
channelType - the channel type. Can be LogConst.STDOUTID, STDERRID or STDFILEID.
logChannel - the channel to add, of the appropriate type.

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.

getLogLevels

public static java.util.Vector getLogLevels()
Get a list of all possible logging levels.

Returns:
a list describing the different logging levels.