org.objectweb.util.monolog.wrapper.config
Class BasicFactory
java.lang.Object
org.objectweb.util.monolog.wrapper.config.BasicFactory
- HandlerFactory, LevelFactory, LoggerFactory, MonologFactory, Serializable
public class BasicFactory
extends java.lang.Object
This class is a basic implementation of the monolog factories
(HandlerFactory, LoggerFactory and LevelFactory). It does not linked to an
any underlying log system.
- Sebastien Chassande-Barrioz
protected HashMap | handlers - This field references the handler instance by their names.
key = a String object which is an handler name.
|
protected HashMap | intToNames - This field reference the level names by their integer value.
key = a java.lang.Integer which the value is the level
value = a String or an ArrayList of String.
|
protected HashMap | loggers - This field references the handler instance by their names.
key = a String object which is a logger topic.
|
protected HashMap | nameToLevel - This field references the level instances by their names.
key = a level name
value = the unique Level instance linked to the name.
|
protected String | resourceBundleName - The resource bundle linked to the LoggerFactory.
|
BasicFactory() - It intializes the data struture, defines the default level and the root
logger.
|
void | configure(Properties prop)
|
Handler | createHandler(String hn, String handlertype) - It retrieves a new instance of an handler which the type is specified
by the parameter.
|
protected void | defineDefaultLevels() - It initializes the default monolog level:
- DEBUG: 10 000
- INFO: 20 000
- WARN: 30 000
- ERROR: 40 000
- FATAL: 50 000
|
Level | defineLevel(String name, String value) - It defines a new Level with a name and a string value.
|
Level | defineLevel(String name, int value) - It defines a new Level with a name and an integer value.
|
protected void | defineRootLogger() - It defines the level of the root logger to WARN.
|
Handler | getHandler(String hn) - It retrieves the handler which the name is specified by the parameter
|
Handler[] | getHandlers() - It retrieves all handler managed by this factory.
|
Level | getLevel(String name) - It retrieves a Level instance which the name is equals to the parameter.
|
Level | getLevel(int value) - It retrieves a Level instance which the integer value is equals to the
parameter.
|
Level[] | getLevels() - It retrieves all Level instances defined in this manager.
|
Logger | getLogger(String _key) - This method permits to fetch a Logger.
|
Logger | getLogger(String key, String resourceBundleName) - This method permits to fetch a Logger.
|
Logger[] | getLoggers() - It retrieves a list of all loggers.
|
String | getResourceBundleName() - Accessors to a resource bundle name associated to a LoggerFactory.
|
Handler | removeHandler(String hn) - It removes the handler which the name is specified by the parameter
|
void | removeLevel(String name) - It removes a Level instance to this manager.
|
void | setResourceBundleName(String rbn) - Accessors to a resource bundle name associated to a LoggerFactory.
|
handlers
protected HashMap handlers
This field references the handler instance by their names.
key = a String object which is an handler name.
value = the unique handler instance which has the key for name.
intToNames
protected HashMap intToNames
This field reference the level names by their integer value.
key = a java.lang.Integer which the value is the level
value = a String or an ArrayList of String. The strings represent the
name which match to the integer value. Indeed both name can be associated
to the same integer value.
loggers
protected HashMap loggers
This field references the handler instance by their names.
key = a String object which is a logger topic.
value = the unique handler instance which has the key for name.
nameToLevel
protected HashMap nameToLevel
This field references the level instances by their names.
key = a level name
value = the unique Level instance linked to the name.
resourceBundleName
protected String resourceBundleName
The resource bundle linked to the LoggerFactory.
BasicFactory
public BasicFactory()
It intializes the data struture, defines the default level and the root
logger.
createHandler
public Handler createHandler(String hn,
String handlertype)
It retrieves a new instance of an handler which the type is specified
by the parameter.
- createHandler in interface HandlerFactory
handlertype
- is the type of the parameter. The possible value are
defined in this interface by the XXX_HANDLER_TYPE constants.
- a new instance of an handler
defineDefaultLevels
protected void defineDefaultLevels()
It initializes the default monolog level:
- DEBUG: 10 000
- INFO: 20 000
- WARN: 30 000
- ERROR: 40 000
- FATAL: 50 000
defineLevel
public Level defineLevel(String name,
String value)
It defines a new Level with a name and a string value. The string value
is analyzed to obtain the integer value.
- defineLevel in interface LevelFactory
name
- is the name of the new levelvalue
- is the string value of the new level
- a Level instance or a null value if It exists a Level with the
same name but with another integer value.
defineLevel
public Level defineLevel(String name,
int value)
It defines a new Level with a name and an integer value.
- defineLevel in interface LevelFactory
name
- is the name of the new levelvalue
- is the integer value of the new level
- a Level instance or a null value if It exists a Level with the
same name but with another integer value.
defineRootLogger
protected void defineRootLogger()
It defines the level of the root logger to WARN.
getHandler
public Handler getHandler(String hn)
It retrieves the handler which the name is specified by the parameter
- getHandler in interface HandlerFactory
- an handler instance or a null value.
getHandlers
public Handler[] getHandlers()
It retrieves all handler managed by this factory.
- getHandlers in interface HandlerFactory
- a set of Handler instance or an empty set.
getLevel
public Level getLevel(String name)
It retrieves a Level instance which the name is equals to the parameter.
- getLevel in interface LevelFactory
name
- is the name of request Level
- a Leve instance or a null value if the level does not exist.
getLevel
public Level getLevel(int value)
It retrieves a Level instance which the integer value is equals to the
parameter.
- getLevel in interface LevelFactory
value
- is the integer value of request Level
- a Leve instance or a null value if the level does not exist. As
it is possible to define several Levels which have the same integer value
this methods returns the Level instance of first name found in the list.
getLogger
public Logger getLogger(String _key)
This method permits to fetch a Logger. If the Logger
described by the parameters does not exist, then the LoggerFactory
must return a new instance of Logger.
The key parameter is a description of the expected Logger. In simple
cases, the key is the initial topic of the Logger.
- getLogger in interface LoggerFactory
getLogger
public Logger getLogger(String key,
String resourceBundleName)
This method permits to fetch a Logger. If the Logger
described by the parameters does not exist, then the LoggerFactory
must return a new instance of Logger.
The key parameter is a description of the expected Logger. In simple
cases, the key is the initial topic of the Logger.
The resourceBundleName parameter allows specifying the name of a
resource bundle in order to internationalise the logging.
- getLogger in interface LoggerFactory
getResourceBundleName
public String getResourceBundleName()
Accessors to a resource bundle name associated to a LoggerFactory.
- getResourceBundleName in interface LoggerFactory
removeHandler
public Handler removeHandler(String hn)
It removes the handler which the name is specified by the parameter
- removeHandler in interface HandlerFactory
- the removed handler instance or a null value if it does not
exist.
removeLevel
public void removeLevel(String name)
It removes a Level instance to this manager.
- removeLevel in interface LevelFactory
setResourceBundleName
public void setResourceBundleName(String rbn)
Accessors to a resource bundle name associated to a LoggerFactory.
- setResourceBundleName in interface LoggerFactory