org.objectweb.util.monolog.wrapper.config
Class BasicLogger

java.lang.Object
  extended byorg.objectweb.util.monolog.wrapper.config.BasicLogger
All Implemented Interfaces:
Handler, Logger, java.io.Serializable, TopicalLogger

public class BasicLogger
extends java.lang.Object
implements TopicalLogger, java.io.Serializable

This class is a basic implementatio of the TopicalLogger interface. It is not linked to any underlying log system. The log methods do nothing. Only the configuration aspect is treated. Therefore all the logger structure is stored into internal struture.

Author:
Sebastien Chassande-Barrioz
See Also:
Serialized Form

Field Summary
protected  java.util.HashMap handlers
          This fields references by their name the handlers associated to the logger.
protected  Level level
          The current level of the logger.
protected  LevelFactory levelFactory
          This field references the level factory.
protected  java.util.ArrayList topics
          The fields lists all topics the logger.
 
Fields inherited from interface org.objectweb.util.monolog.api.Handler
APPEND_MODE_ATTRIBUTE, CONSOLE_HANDLER_TYPE, FILE_HANDLER_TYPE, FILE_NUMBER_ATTRIBUTE, GENERIC_HANDLER_TYPE, LOGGER_HANDLER_TYPE, MAX_SIZE_ATTRIBUTE, OUTPUT_ATTRIBUTE, PATTERN_ATTRIBUTE, ROLLING_FILE_HANDLER_TYPE
 
Method Summary
 void addHandler(Handler h)
          A TopicalLogger manages a list of Handler instances.
 void addTopic(java.lang.String topic)
          This method allows adding a topic to a TopicalLogger.
 boolean getAdditivity()
          It retrieves the additivity flag for this logger instance.
 java.lang.Object getAttribute(java.lang.String name)
          It retrieves the value of an attribute value of the handler.
 java.lang.String[] getAttributeNames()
          It retrieves the attributes of the handler
 int getCurrentIntLevel()
          Returns the current level value under the integer format
 Level getCurrentLevel()
          Returns the current level value under the Level format
 Handler[] getHandler()
          It returns the list of the handler associated to this logger.
 Handler getHandler(java.lang.String hn)
          It returns the handler which the name is equals to the parameter
 java.lang.String getName()
          It retrieves the name of the handler
 java.lang.String[] getTopic()
          This method allows getting a topic list of this TopicalLogger.
 java.util.Enumeration getTopics()
          TODO
 byte getType()
          It retrieves the Handler type
 boolean isLoggable(int level)
          Check if a message of the given level would actually be logged by this logger.
 boolean isLoggable(Level l)
          Check if a message of the given level would actually be logged by this logger.
 boolean isOn()
          Check if this logger is enabled.
 void log(int level, java.lang.Object message)
          Log a message, with no arguments.
 void log(int level, java.lang.Object message, java.lang.Object location, java.lang.Object method)
          Log a message, with a location and method arguments.
 void log(int level, java.lang.Object message, java.lang.Throwable throwable)
          Log a message, with a throwable arguments which can represent an error or a context..
 void log(int level, java.lang.Object message, java.lang.Throwable throwable, java.lang.Object location, java.lang.Object method)
          Log a message, with a location, method and throwable arguments.
 void log(Level level, java.lang.Object message)
          Log a message, with no arguments.
 void log(Level l, java.lang.Object message, java.lang.Object location, java.lang.Object method)
          Log a message, with a location and method arguments.
 void log(Level level, java.lang.Object message, java.lang.Throwable throwable)
          Log a message, with a throwable arguments which can represent an error or a context..
 void log(Level level, java.lang.Object message, java.lang.Throwable throwable, java.lang.Object location, java.lang.Object method)
          Log a message, with a location, method and throwable arguments.
 void removeAllHandlers()
          A TopicalLogger manages a list of Handler instances.
 void removeHandler(Handler h)
          A TopicalLogger manages a list of Handler instances.
 void removeTopic(java.lang.String topic)
          This method allows removing a topic to a TopicalLogger.
 void setAdditivity(boolean a)
          It assigns the additivity flag for this logger instance.
 java.lang.Object setAttribute(java.lang.String name, java.lang.Object value)
          It assigns an attributte to the handler.
 void setIntLevel(int l)
          Permits to set the level with an integer value
 void setLevel(Level l)
          Permits to set the level with a Level instance.
 void setName(java.lang.String name)
          It assigns the name of the handler
 void turnOff()
          Disables this logger
 void turnOn()
          Enables this logger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

handlers

protected java.util.HashMap handlers
This fields references by their name the handlers associated to the logger. key = a handler name value = a Handler instance


topics

protected java.util.ArrayList topics
The fields lists all topics the logger.


levelFactory

protected LevelFactory levelFactory
This field references the level factory.


level

protected Level level
The current level of the logger.

Method Detail

addHandler

public void addHandler(Handler h)
                throws java.lang.Exception
Description copied from interface: TopicalLogger
A TopicalLogger manages a list of Handler instances. This method allows adding a handler to this list. The addHandler method returns true only if the Handler did not exist

Specified by:
addHandler in interface TopicalLogger
Throws:
java.lang.Exception

removeHandler

public void removeHandler(Handler h)
                   throws java.lang.Exception
Description copied from interface: TopicalLogger
A TopicalLogger manages a list of Handler instances. This method allows removing a handler to this list.

Specified by:
removeHandler in interface TopicalLogger
Throws:
java.lang.Exception

getHandler

public Handler[] getHandler()
Description copied from interface: TopicalLogger
It returns the list of the handler associated to this logger.

Specified by:
getHandler in interface TopicalLogger
Returns:
an array of Handler or an empty array.

getHandler

public Handler getHandler(java.lang.String hn)
Description copied from interface: TopicalLogger
It returns the handler which the name is equals to the parameter

Specified by:
getHandler in interface TopicalLogger
Returns:
an Handler or a null value.

removeAllHandlers

public void removeAllHandlers()
                       throws java.lang.Exception
Description copied from interface: TopicalLogger
A TopicalLogger manages a list of Handler instances. This method allows removing all handler.

Specified by:
removeAllHandlers in interface TopicalLogger
Throws:
java.lang.Exception

setAdditivity

public void setAdditivity(boolean a)
Description copied from interface: TopicalLogger
It assigns the additivity flag for this logger instance.

Specified by:
setAdditivity in interface TopicalLogger

getAdditivity

public boolean getAdditivity()
Description copied from interface: TopicalLogger
It retrieves the additivity flag for this logger instance.

Specified by:
getAdditivity in interface TopicalLogger

addTopic

public void addTopic(java.lang.String topic)
              throws java.lang.Exception
Description copied from interface: TopicalLogger
This method allows adding a topic to a TopicalLogger. This actions change the hierarchical structure, but also the list of handlers. The list of handlers of a TopicalLogger is composed of its handlers and all handlers inherited from its parents. Adding a topic changes the inherited handlers list.

Specified by:
addTopic in interface TopicalLogger
Throws:
java.lang.Exception

getTopics

public java.util.Enumeration getTopics()
TODO

Specified by:
getTopics in interface TopicalLogger

getTopic

public java.lang.String[] getTopic()
Description copied from interface: TopicalLogger
This method allows getting a topic list of this TopicalLogger.

Specified by:
getTopic in interface TopicalLogger

removeTopic

public void removeTopic(java.lang.String topic)
                 throws java.lang.Exception
Description copied from interface: TopicalLogger
This method allows removing a topic to a TopicalLogger. This actions change the hierarchical structure, but also the list of handlers. The list of handlers of a TopicalLogger is composed of its handlers and all handlers inherited from its parents. Removing a topic changes the inherited handlers list.

Specified by:
removeTopic in interface TopicalLogger
Throws:
java.lang.Exception

getName

public java.lang.String getName()
Description copied from interface: Handler
It retrieves the name of the handler

Specified by:
getName in interface Handler

setName

public void setName(java.lang.String name)
Description copied from interface: Handler
It assigns the name of the handler

Specified by:
setName in interface Handler

getType

public byte getType()
Description copied from interface: Handler
It retrieves the Handler type

Specified by:
getType in interface Handler

getAttributeNames

public java.lang.String[] getAttributeNames()
Description copied from interface: Handler
It retrieves the attributes of the handler

Specified by:
getAttributeNames in interface Handler

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
Description copied from interface: Handler
It retrieves the value of an attribute value of the handler.

Specified by:
getAttribute in interface Handler

setAttribute

public java.lang.Object setAttribute(java.lang.String name,
                                     java.lang.Object value)
Description copied from interface: Handler
It assigns an attributte to the handler.

Specified by:
setAttribute in interface Handler
Parameters:
value - is the attribute value
Returns:
the old value is the attribute was already defined

setIntLevel

public void setIntLevel(int l)
Description copied from interface: Logger
Permits to set the level with an integer value

Specified by:
setIntLevel in interface Logger

setLevel

public void setLevel(Level l)
Description copied from interface: Logger
Permits to set the level with a Level instance.

Specified by:
setLevel in interface Logger

getCurrentIntLevel

public int getCurrentIntLevel()
Description copied from interface: Logger
Returns the current level value under the integer format

Specified by:
getCurrentIntLevel in interface Logger

getCurrentLevel

public Level getCurrentLevel()
Description copied from interface: Logger
Returns the current level value under the Level format

Specified by:
getCurrentLevel in interface Logger

isLoggable

public boolean isLoggable(int level)
Description copied from interface: Logger
Check if a message of the given level would actually be logged by this logger.

Specified by:
isLoggable in interface Logger

isLoggable

public boolean isLoggable(Level l)
Description copied from interface: Logger
Check if a message of the given level would actually be logged by this logger.

Specified by:
isLoggable in interface Logger

isOn

public boolean isOn()
Description copied from interface: Logger
Check if this logger is enabled.

Specified by:
isOn in interface Logger

log

public void log(int level,
                java.lang.Object message)
Description copied from interface: Logger
Log a message, with no arguments. If the logger is currently enabled for the given message level then the given message is treated

Specified by:
log in interface Logger

log

public void log(Level level,
                java.lang.Object message)
Description copied from interface: Logger
Log a message, with no arguments. If the logger is currently enabled for the given message level then the given message is treated

Specified by:
log in interface Logger

log

public void log(int level,
                java.lang.Object message,
                java.lang.Throwable throwable)
Description copied from interface: Logger
Log a message, with a throwable arguments which can represent an error or a context..

Specified by:
log in interface Logger

log

public void log(Level level,
                java.lang.Object message,
                java.lang.Throwable throwable)
Description copied from interface: Logger
Log a message, with a throwable arguments which can represent an error or a context..

Specified by:
log in interface Logger

log

public void log(int level,
                java.lang.Object message,
                java.lang.Object location,
                java.lang.Object method)
Description copied from interface: Logger
Log a message, with a location and method arguments. The location parameter can be the object instance which logs the event, or a string representation of the object. The method argument can be a java.lang.reflect.Method or a string which represents the method name.

Specified by:
log in interface Logger

log

public void log(Level l,
                java.lang.Object message,
                java.lang.Object location,
                java.lang.Object method)
Description copied from interface: Logger
Log a message, with a location and method arguments. The location parameter can be the object instance which logs the event, or a string representation of the object. The method argument can be a java.lang.reflect.Method or a string which represents the method name.

Specified by:
log in interface Logger

log

public void log(int level,
                java.lang.Object message,
                java.lang.Throwable throwable,
                java.lang.Object location,
                java.lang.Object method)
Description copied from interface: Logger
Log a message, with a location, method and throwable arguments. The location parameter can be the object instance which logs the event, or a string representation of the object.. The method argument can be a java.lang.reflect.Method or a string which represents the method name. The throwable parameter permits to log an Exception.

Specified by:
log in interface Logger

log

public void log(Level level,
                java.lang.Object message,
                java.lang.Throwable throwable,
                java.lang.Object location,
                java.lang.Object method)
Description copied from interface: Logger
Log a message, with a location, method and throwable arguments. The location parameter can be the object instance which logs the event, or a string representation of the object.. The method argument can be a java.lang.reflect.Method or a string which represents the method name. The throwable parameter permits to log an Exception.

Specified by:
log in interface Logger

turnOn

public void turnOn()
Description copied from interface: Logger
Enables this logger

Specified by:
turnOn in interface Logger

turnOff

public void turnOff()
Description copied from interface: Logger
Disables this logger

Specified by:
turnOff in interface Logger