org.objectweb.util.monolog.wrapper.config

Class BasicLogger

Implemented Interfaces:
Handler, Logger, Serializable, TopicalLogger

public class BasicLogger
extends java.lang.Object
implements TopicalLogger, 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

Field Summary

protected 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 ArrayList
topics
The fields lists all topics the logger.

Fields inherited from interface org.objectweb.util.monolog.api.Handler

APPEND_MODE_ATTRIBUTE, BUFFER_ATTRIBUTE, CONSOLE_HANDLER_TYPE, FILE_HANDLER_TYPE, FILE_NUMBER_ATTRIBUTE, GENERIC_HANDLER_TYPE, LEVEL_ATTRIBUTE, 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(String topic)
This method allows adding a topic to a TopicalLogger.
boolean
getAdditivity()
It retrieves the additivity flag for this logger instance.
Object
getAttribute(String name)
String[]
getAttributeNames()
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(String hn)
It returns the handler which the name is equals to the parameter
String
getName()
String[]
getTopic()
This method allows getting a topic list of this TopicalLogger.
Enumeration
getTopics()
TODO
String
getType()
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, Object message)
Log a message, with no arguments.
void
log(int level, Object message, Object location, Object method)
Log a message, with a location and method arguments.
void
log(int level, Object message, Throwable throwable)
Log a message, with a throwable arguments which can represent an error or a context..
void
log(int level, Object message, Throwable throwable, Object location, Object method)
Log a message, with a location, method and throwable arguments.
void
log(Level level, Object message)
Log a message, with no arguments.
void
log(Level l, Object message, Object location, Object method)
Log a message, with a location and method arguments.
void
log(Level level, Object message, Throwable throwable)
Log a message, with a throwable arguments which can represent an error or a context..
void
log(Level level, Object message, Throwable throwable, Object location, 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(String topic)
This method allows removing a topic to a TopicalLogger.
void
setAdditivity(boolean a)
It assigns the additivity flag for this logger instance.
Object
setAttribute(String name, Object value)
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(String name)
void
turnOff()
Disables this logger
void
turnOn()
Enables this logger

Field Details

handlers

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


level

protected Level level
The current level of the logger.


levelFactory

protected LevelFactory levelFactory
This field references the level factory.


topics

protected ArrayList topics
The fields lists all topics the logger.

Method Details

addHandler

public void addHandler(Handler h)
            throws Exception
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


addTopic

public void addTopic(String topic)
            throws Exception
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


getAdditivity

public boolean getAdditivity()
It retrieves the additivity flag for this logger instance.
Specified by:
getAdditivity in interface TopicalLogger


getAttribute

public Object getAttribute(String name)
Specified by:
getAttribute in interface Handler


getAttributeNames

public String[] getAttributeNames()
Specified by:
getAttributeNames in interface Handler


getCurrentIntLevel

public int getCurrentIntLevel()
Returns the current level value under the integer format
Specified by:
getCurrentIntLevel in interface Logger


getCurrentLevel

public Level getCurrentLevel()
Returns the current level value under the Level format
Specified by:
getCurrentLevel in interface Logger


getHandler

public Handler[] getHandler()
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(String hn)
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.


getName

public String getName()
Specified by:
getName in interface Handler


getTopic

public String[] getTopic()
This method allows getting a topic list of this TopicalLogger.
Specified by:
getTopic in interface TopicalLogger


getTopics

public Enumeration getTopics()
TODO
Specified by:
getTopics in interface TopicalLogger


getType

public String getType()
Specified by:
getType in interface Handler


isLoggable

public boolean isLoggable(int level)
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)
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()
Check if this logger is enabled.
Specified by:
isOn in interface Logger


log

public void log(int level,
                Object message)
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,
                Object message,
                Object location,
                Object method)
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,
                Object message,
                Throwable throwable)
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,
                Object message,
                Throwable throwable,
                Object location,
                Object method)
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,
                Object message)
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 l,
                Object message,
                Object location,
                Object method)
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 level,
                Object message,
                Throwable throwable)
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,
                Object message,
                Throwable throwable,
                Object location,
                Object method)
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


removeAllHandlers

public void removeAllHandlers()
            throws Exception
A TopicalLogger manages a list of Handler instances. This method allows removing all handler.
Specified by:
removeAllHandlers in interface TopicalLogger


removeHandler

public void removeHandler(Handler h)
            throws Exception
A TopicalLogger manages a list of Handler instances. This method allows removing a handler to this list.
Specified by:
removeHandler in interface TopicalLogger


removeTopic

public void removeTopic(String topic)
            throws Exception
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


setAdditivity

public void setAdditivity(boolean a)
It assigns the additivity flag for this logger instance.
Specified by:
setAdditivity in interface TopicalLogger


setAttribute

public Object setAttribute(String name,
                           Object value)
Specified by:
setAttribute in interface Handler


setIntLevel

public void setIntLevel(int l)
Permits to set the level with an integer value
Specified by:
setIntLevel in interface Logger


setLevel

public void setLevel(Level l)
Permits to set the level with a Level instance.
Specified by:
setLevel in interface Logger


setName

public void setName(String name)
Specified by:
setName in interface Handler


turnOff

public void turnOff()
Disables this logger
Specified by:
turnOff in interface Logger


turnOn

public void turnOn()
Enables this logger
Specified by:
turnOn in interface Logger