com.sdm.quasar.client.core.common.logging.impl
Class SimpleConsoleLogHandler

java.lang.Object
  extended bycom.sdm.quasar.client.core.common.logging.impl.SimpleConsoleLogHandler
All Implemented Interfaces:
LogHandler

public class SimpleConsoleLogHandler
extends java.lang.Object
implements LogHandler

Primitive logger factory that creates SimpleConsoleLoggers. This implementation acts as a fallback if the LogManager is not initialized.

Version:
1.0
Author:
Bernd Olleck, sd&m AG

Field Summary
static java.lang.String DEFAULT_MESSAGE_PATTERN
          The default message pattern used to format log messages.
 
Constructor Summary
protected SimpleConsoleLogHandler()
          Creates a new SimpleConsoleLogHandler.
protected SimpleConsoleLogHandler(java.lang.String messagePattern, int[] errorLoggingLevels)
          Creates a new SimpleConsoleLogHandler.
 
Method Summary
 java.lang.String getMessagePattern()
          Returns the message format pattern used to format log messages.
 boolean handles(int loggingLevel, CallerInformation callerInformation)
          Returns true, if the LogHandler can handle logging messages for the calling logger and logging level.
 boolean isErrorLoggingLevel(int loggingLevel)
          Returns true, if the given logging level is an 'error' logging level or a normal one.
 boolean isLogging(int loggingLevel, CallerInformation callerInformation)
          Tests, whether messages will be logged at the given logging level
 void log(int loggingLevel, CallerInformation callerInformation, java.lang.String message, java.lang.Throwable exception)
          Logs a message including an optional exception if logging is enabled for the specified calling logger and logging level.
 void setMessagePattern(java.lang.String messagePattern)
          Sets the message format pattern used to format log messages.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_MESSAGE_PATTERN

public static final java.lang.String DEFAULT_MESSAGE_PATTERN
The default message pattern used to format log messages.

See Also:
Constant Field Values
Constructor Detail

SimpleConsoleLogHandler

protected SimpleConsoleLogHandler()
Creates a new SimpleConsoleLogHandler.


SimpleConsoleLogHandler

protected SimpleConsoleLogHandler(java.lang.String messagePattern,
                                  int[] errorLoggingLevels)
Creates a new SimpleConsoleLogHandler.

Parameters:
messagePattern - the message-patter to use (if null, use default)
errorLoggingLevels - the logging levels, that should be used as error logging levels (if null, use default)
Method Detail

handles

public boolean handles(int loggingLevel,
                       CallerInformation callerInformation)
Description copied from interface: LogHandler
Returns true, if the LogHandler can handle logging messages for the calling logger and logging level.

Specified by:
handles in interface LogHandler
Parameters:
loggingLevel - the level to be logged, one of the constants from LoggingLevel
callerInformation - stores information about the logger caller (garanteed to be not null)
Returns:
true, iff this LogHandler can handle logging messages for the logger class and logging level given
See Also:
LogHandler.handles(int, com.sdm.quasar.client.core.common.logging.CallerInformation)

isLogging

public boolean isLogging(int loggingLevel,
                         CallerInformation callerInformation)
Description copied from interface: LogHandler
Tests, whether messages will be logged at the given logging level

Specified by:
isLogging in interface LogHandler
Parameters:
loggingLevel - the level to be logged, one of the constants from LoggingLevel
callerInformation - stores information about the logger caller (garanteed to be not null)
Returns:
true, iff messages will be logged at the given level
See Also:
LogHandler.isLogging(int, com.sdm.quasar.client.core.common.logging.CallerInformation)

log

public void log(int loggingLevel,
                CallerInformation callerInformation,
                java.lang.String message,
                java.lang.Throwable exception)
Description copied from interface: LogHandler
Logs a message including an optional exception if logging is enabled for the specified calling logger and logging level.

Specified by:
log in interface LogHandler
Parameters:
loggingLevel - the level to be logged, one of the constants from LoggingLevel
callerInformation - stores information about the logger caller (garanteed to be not null)
message - the message to be logged (may be null)
exception - the exception to be logged (may be null)
See Also:
LogHandler.log(int, com.sdm.quasar.client.core.common.logging.CallerInformation, java.lang.String, java.lang.Throwable)

isErrorLoggingLevel

public boolean isErrorLoggingLevel(int loggingLevel)
Returns true, if the given logging level is an 'error' logging level or a normal one.

Parameters:
loggingLevel - the logging level to check
Returns:
true if the logging level should be logged as error, false otherwise.

getMessagePattern

public java.lang.String getMessagePattern()
Returns the message format pattern used to format log messages.

Returns:
the message format pattern.

setMessagePattern

public void setMessagePattern(java.lang.String messagePattern)
Sets the message format pattern used to format log messages.