org.objectweb.util.monolog.wrapper.log4j
Class MonologCategory

java.lang.Object
  extended by org.apache.log4j.Category
      extended by org.apache.log4j.Logger
          extended by org.objectweb.util.monolog.wrapper.log4j.MonologCategory
All Implemented Interfaces:
org.apache.log4j.spi.AppenderAttachable, Handler, Logger, TopicalLogger

public class MonologCategory
extends org.apache.log4j.Logger
implements TopicalLogger

This class wraps the Logger concept into the log4j world. This class extends therefore the Logger class. This implementation supports

Author:
Sebastien Chassande-Barrioz

Nested Class Summary
static class MonologCategory.BetaCF
           
static class MonologCategory.OwPriority
           
 
Field Summary
protected  ArrayList appenders
          This field references all appenders associated to the current Logger
protected  org.apache.log4j.Logger categ
          This field references the inner Logger if the delegation was choosen.
protected  byte depth
           
protected static int DISABLE_OFF
           
protected static int DISABLE_ON
           
protected  boolean enable
           
protected  MonologCategory.OwPriority interPriority
           
protected  HashMap topicToparents
          This field references all parent of this Logger.
 
Fields inherited from class org.apache.log4j.Category
additive, level, name, parent, repository, resourceBundle
 
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, JMX_HANDLER_TYPE, LEVEL_ATTRIBUTE, LOGGER_HANDLER_TYPE, MAX_SIZE_ATTRIBUTE, OUTPUT_ATTRIBUTE, PATTERN_ATTRIBUTE, ROLLING_FILE_HANDLER_TYPE
 
Constructor Summary
MonologCategory(org.apache.log4j.Logger c)
          This constructor initializes the instance in delegation mode.
MonologCategory(String _initialName)
          This constructor initializes the instance in inheritance mode.
 
Method Summary
 void addHandler(Handler h)
          Add a handler in the Handler list of the topicalLogger
 void addTopic(String topic)
          Add a topic to the topicalLogger
 void callAppenders(org.apache.log4j.spi.LoggingEvent event)
          In inheritance mode this method delegates the treatment to the other callAppendes methods.
 boolean callAppenders(org.apache.log4j.spi.LoggingEvent event, boolean called)
          This method calls all the parent loggers and call its appender either the followin condition: if the called parameter is equals to true then all parent are call with the same value, and the logging event are transmitted to the appenders.
static String format(String msg, int removeTopStack)
          It formats a message by adding the object and the method name where the call to monolog was done.
 Object getAttribute(String name)
           
 String[] getAttributeNames()
           
 org.apache.log4j.Level getChainedLevel()
          Starting from this Logger, search the Logger hierarchy for a non-null priority and return it.
 int getCurrentIntLevel()
          Return the current Level of the logger
 Level getCurrentLevel()
           
 Handler[] getHandler()
           
 Handler getHandler(String hn)
           
 String[] getTopic()
          Returns the list of the different names of the topicalLogger
 Enumeration getTopics()
          Returns the list of the different names of the topicalLogger
 String getType()
           
 boolean isLoggable(int l)
          Check if the level parameter are not filtered by the logger
 boolean isLoggable(Level l)
           
 boolean isOn()
          Is the handler enabled
 void log(int l, Object o)
          Log an object with a specific level.
 void log(int l, Object o, Object location, Object method)
          Log an object and a trowable with a specific level.
 void log(int l, Object o, Throwable t)
          Log an object and a trowable with a specific level.
 void log(int l, Object o, Throwable t, Object location, Object method)
          Log an object and a trowable with a specific level.
 void log(Level l, Object o)
           
 void log(Level l, Object o, Object location, Object method)
           
 void log(Level l, Object o, Throwable t)
           
 void log(Level l, Object o, Throwable t, Object location, Object method)
           
 void removeAllHandlers()
           
 void removeHandler(Handler h)
          Remove a handler from the Handler list of the topicalLogger
 void removeTopic(String topic)
          Remove a topic from the topicalLogger
 Object setAttribute(String name, Object value)
           
 void setIntLevel(int level)
          Set the current level of the logger
 void setLevel(Level l)
           
 void setName(String n)
           
 void turnOff()
          Disable the handler
 void turnOn()
          Enable the handler
 
Methods inherited from class org.apache.log4j.Logger
getLogger, getLogger, getLogger, getRootLogger, isTraceEnabled, trace, trace
 
Methods inherited from class org.apache.log4j.Category
addAppender, assertLog, debug, debug, error, error, exists, fatal, fatal, forcedLog, getAdditivity, getAllAppenders, getAppender, getChainedPriority, getCurrentCategories, getDefaultHierarchy, getEffectiveLevel, getHierarchy, getInstance, getInstance, getLevel, getLoggerRepository, getName, getParent, getPriority, getResourceBundle, getResourceBundleString, getRoot, info, info, isAttached, isDebugEnabled, isEnabledFor, isInfoEnabled, l7dlog, l7dlog, log, log, log, removeAllAppenders, removeAppender, removeAppender, setAdditivity, setLevel, setPriority, setResourceBundle, shutdown, warn, warn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.objectweb.util.monolog.api.TopicalLogger
getAdditivity, setAdditivity
 
Methods inherited from interface org.objectweb.util.monolog.api.Handler
getName
 

Field Detail

enable

protected boolean enable

DISABLE_OFF

protected static final int DISABLE_OFF
See Also:
Constant Field Values

DISABLE_ON

protected static final int DISABLE_ON

interPriority

protected MonologCategory.OwPriority interPriority

depth

protected byte depth

topicToparents

protected HashMap topicToparents
This field references all parent of this Logger. key = topic of the current logger value = its parent either the topic. A parent can be a MonologCategory or a Logger.


appenders

protected ArrayList appenders
This field references all appenders associated to the current Logger


categ

protected org.apache.log4j.Logger categ
This field references the inner Logger if the delegation was choosen.

Constructor Detail

MonologCategory

public MonologCategory(String _initialName)
This constructor initializes the instance in inheritance mode. It initializes the instanceFQN, and struture of parents.


MonologCategory

public MonologCategory(org.apache.log4j.Logger c)
This constructor initializes the instance in delegation mode.

Parameters:
c - is the inner Logger. All calls will be foward to this instance
Method Detail

format

public static String format(String msg,
                            int removeTopStack)
It formats a message by adding the object and the method name where the call to monolog was done.

Parameters:
msg - is the original message
removeTopStack - is the number of monolog method call. Indeed this method fetch a stack trace. This method fetches one line in this stack. The parameter is the line number in this stack.

getChainedLevel

public org.apache.log4j.Level getChainedLevel()
Starting from this Logger, search the Logger hierarchy for a non-null priority and return it. Otherwise, return the priority of the root Logger.

The Logger class is designed so that this method executes as quickly as possible.


callAppenders

public void callAppenders(org.apache.log4j.spi.LoggingEvent event)
In inheritance mode this method delegates the treatment to the other callAppendes methods. In delegation mode, the call is forwarded on the inner Logger instance.

Overrides:
callAppenders in class org.apache.log4j.Category

callAppenders

public boolean callAppenders(org.apache.log4j.spi.LoggingEvent event,
                             boolean called)
This method calls all the parent loggers and call its appender either the followin condition:

Parameters:
event - is the logging event
called - is the boolean which permits to know if the current logger must call or not its appender without check its priority. return true is the logging event is enabled in the current logger or one of its ancestors.

isLoggable

public boolean isLoggable(int l)
Check if the level parameter are not filtered by the logger

Specified by:
isLoggable in interface Logger

isLoggable

public boolean isLoggable(Level l)
Specified by:
isLoggable in interface Logger

isOn

public boolean isOn()
Is the handler enabled

Specified by:
isOn in interface Logger

log

public void log(int l,
                Object o)
Log an object with a specific level. If the level parameter is loggable the object is handled.

Specified by:
log in interface Logger

log

public void log(Level l,
                Object o)
Specified by:
log in interface Logger

log

public void log(int l,
                Object o,
                Throwable t)
Log an object and a trowable with a specific level.

Specified by:
log in interface Logger

log

public void log(Level l,
                Object o,
                Throwable t)
Specified by:
log in interface Logger

log

public void log(int l,
                Object o,
                Object location,
                Object method)
Log an object and a trowable with a specific level. This method permits to specify an object instance and a method.

Specified by:
log in interface Logger

log

public void log(Level l,
                Object o,
                Object location,
                Object method)
Specified by:
log in interface Logger

log

public void log(int l,
                Object o,
                Throwable t,
                Object location,
                Object method)
Log an object and a trowable with a specific level. This method permits to specify an object instance and a method.

Specified by:
log in interface Logger

log

public void log(Level l,
                Object o,
                Throwable t,
                Object location,
                Object method)
Specified by:
log in interface Logger

turnOn

public void turnOn()
Enable the handler

Specified by:
turnOn in interface Logger

turnOff

public void turnOff()
Disable the handler

Specified by:
turnOff in interface Logger

setIntLevel

public void setIntLevel(int level)
Set the current level of the logger

Specified by:
setIntLevel in interface Logger

setLevel

public void setLevel(Level l)
Specified by:
setLevel in interface Logger

getCurrentIntLevel

public int getCurrentIntLevel()
Return the current Level of the logger

Specified by:
getCurrentIntLevel in interface Logger

getCurrentLevel

public Level getCurrentLevel()
Specified by:
getCurrentLevel in interface Logger

addHandler

public void addHandler(Handler h)
                throws Exception
Add a handler in the Handler list of the topicalLogger

Specified by:
addHandler in interface TopicalLogger
Throws:
Exception

addTopic

public void addTopic(String topic)
              throws Exception
Add a topic to the topicalLogger

Specified by:
addTopic in interface TopicalLogger
Throws:
Exception

getHandler

public Handler[] getHandler()
Specified by:
getHandler in interface TopicalLogger

getHandler

public Handler getHandler(String hn)
Specified by:
getHandler in interface TopicalLogger

removeAllHandlers

public void removeAllHandlers()
                       throws Exception
Specified by:
removeAllHandlers in interface TopicalLogger
Throws:
Exception

getTopics

public Enumeration getTopics()
Returns the list of the different names of the topicalLogger

Specified by:
getTopics in interface TopicalLogger

getTopic

public String[] getTopic()
Returns the list of the different names of the topicalLogger

Specified by:
getTopic in interface TopicalLogger

removeHandler

public void removeHandler(Handler h)
                   throws Exception
Remove a handler from the Handler list of the topicalLogger

Specified by:
removeHandler in interface TopicalLogger
Throws:
Exception

removeTopic

public void removeTopic(String topic)
                 throws Exception
Remove a topic from the topicalLogger

Specified by:
removeTopic in interface TopicalLogger
Throws:
Exception

setName

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

getType

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

getAttributeNames

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

getAttribute

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

setAttribute

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


Copyright © 2012 OW2 Consortium. All Rights Reserved.