org.objectweb.util.monolog.wrapper.printwriter
Class LoggerImpl

java.lang.Object
  extended by org.objectweb.util.monolog.wrapper.printwriter.LoggerImpl
All Implemented Interfaces:
Handler, HandlerFactory, LevelFactory, Logger, LoggerFactory, MonologFactory, TopicalLogger

public class LoggerImpl
extends Object
implements TopicalLogger, MonologFactory

This class is a simple implementation of the Logger interface provided by the monolog specification.

Author:
sebastien.chassande@inrialpes.fr

Field Summary
protected  boolean additivity
           
protected  Hashtable handlers
           
protected  Map levels
           
protected  String name
           
static String PRINT_WRITER
           
protected  Vector topics
           
 
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
 
Fields inherited from interface org.objectweb.util.monolog.api.MonologFactory
DEFAULT, LOG_CONFIGURATION_FILE, LOG_CONFIGURATION_FILE_USE_CLASSPATH, LOG_CONFIGURATION_TYPE, PROPERTY, XML
 
Constructor Summary
LoggerImpl()
          This constructor permits to specify the printWriter linked to this logger
LoggerImpl(PrintWriter _pw)
          This constructor permits to specify the printWriter linked to this logger
LoggerImpl(String n, PrintWriter _pw)
          This constructor permits to specify the printWriter linked to this logger
 
Method Summary
 void addHandler(Handler h)
           
 void addLogInfo(Character pattern, LogInfo logInfoProvider)
          Set the extension
 void addMonologFactoryListener(MonologFactoryListener mfl)
           
 void addTopic(String topic)
           
 void configure(Properties prop)
           
 Handler createHandler(String hn, String handlertype)
           
 Level defineLevel(String name, int value)
           
 Level defineLevel(String name, String value)
           
static String format(String msg, int removeTopStack)
          This method permits to format messages.
 boolean getAdditivity()
           
 Object getAttribute(String name)
           
 String[] getAttributeNames()
           
 int getCurrentIntLevel()
          Gets the CurrentIntLevel attribute of the LoggerImpl object
 Level getCurrentLevel()
          Gets the CurrentLevel attribute of the LoggerImpl object
 Handler[] getHandler()
           
 Handler getHandler(String hn)
           
 Handler[] getHandlers()
           
 Level getLevel(int value)
          This method is not synchronized because the configuration is rarely
 Level getLevel(String name)
           
 Level[] getLevels()
          This method is not synchronized because the configuration is rarely
 Logger getLogger(String key)
           
 Logger getLogger(String key, String resourceBundleName)
           
 Logger[] getLoggers()
           
 LogInfo getLogInfo(Character pattern)
          Gets the provider of the extension
 String getName()
           
 PrintWriter getPrintWriter()
           
 String getResourceBundleName()
           
 String[] getTopic()
           
 String getTopicPrefix()
           
 Enumeration getTopics()
          Gets the Topics attribute of the LoggerImpl object
 String getType()
           
 boolean isLoggable(int l)
          Gets the Loggable attribute of the LoggerImpl object
 boolean isLoggable(Level l)
          Gets the Loggable attribute of the LoggerImpl object
 boolean isOn()
          Gets the On attribute of the LoggerImpl object
 void log(int level, Object o)
          Log method
 void log(int level, Object o, Object location, Object method)
          Log method
 void log(int level, Object o, Throwable t)
          Log method
 void log(int level, Object o, Throwable t, Object location, Object method)
          Log method
 void log(Level l, Object o)
          Log method
 void log(Level l, Object o, Object location, Object method)
          Log method
 void log(Level l, Object o, Throwable t)
          Log method
 void log(Level l, Object o, Throwable t, Object location, Object method)
          Log method
 void removeAllHandlers()
           
 void removeHandler(Handler h)
           
 Handler removeHandler(String handlername)
           
 void removeLevel(String name)
           
 void removeLogInfo(char pattern)
          Remove an extension
 void removeMonologFactoryListener(MonologFactoryListener mfl)
           
 void removeTopic(String topic)
           
 void setAdditivity(boolean a)
           
 Object setAttribute(String name, Object value)
           
 void setIntLevel(int l)
          Sets the IntLevel attribute of the LoggerImpl object
 void setLevel(Level l)
          Sets the Level attribute of the LoggerImpl object
 void setName(String n)
           
 void setResourceBundleName(String resourceBundleName)
           
 String toString()
          The toString method is override to signal the logger imlementation fowards its messages to a printwriter
 void turnOff()
          Turn off this logger
 void turnOn()
          Turn on this logger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PRINT_WRITER

public static final String PRINT_WRITER
See Also:
Constant Field Values

name

protected String name

topics

protected Vector topics

handlers

protected Hashtable handlers

additivity

protected boolean additivity

levels

protected Map levels
Constructor Detail

LoggerImpl

public LoggerImpl()
This constructor permits to specify the printWriter linked to this logger


LoggerImpl

public LoggerImpl(PrintWriter _pw)
This constructor permits to specify the printWriter linked to this logger

Parameters:
_pw - the printwriter

LoggerImpl

public LoggerImpl(String n,
                  PrintWriter _pw)
This constructor permits to specify the printWriter linked to this logger

Parameters:
_pw - the printwriter
Method Detail

getPrintWriter

public PrintWriter getPrintWriter()

addMonologFactoryListener

public void addMonologFactoryListener(MonologFactoryListener mfl)
Specified by:
addMonologFactoryListener in interface MonologFactory

removeMonologFactoryListener

public void removeMonologFactoryListener(MonologFactoryListener mfl)
Specified by:
removeMonologFactoryListener in interface MonologFactory

configure

public void configure(Properties prop)
               throws Exception
Specified by:
configure in interface MonologFactory
Throws:
Exception

createHandler

public Handler createHandler(String hn,
                             String handlertype)
Specified by:
createHandler in interface HandlerFactory

removeHandler

public Handler removeHandler(String handlername)
Specified by:
removeHandler in interface HandlerFactory

getHandlers

public Handler[] getHandlers()
Specified by:
getHandlers in interface HandlerFactory

defineLevel

public Level defineLevel(String name,
                         int value)
Specified by:
defineLevel in interface LevelFactory

defineLevel

public Level defineLevel(String name,
                         String value)
Specified by:
defineLevel in interface LevelFactory

getLevel

public Level getLevel(String name)
Specified by:
getLevel in interface LevelFactory

getLevel

public Level getLevel(int value)
This method is not synchronized because the configuration is rarely

Specified by:
getLevel in interface LevelFactory

getLevels

public Level[] getLevels()
This method is not synchronized because the configuration is rarely

Specified by:
getLevels in interface LevelFactory

removeLevel

public void removeLevel(String name)
Specified by:
removeLevel in interface LevelFactory

getLogger

public Logger getLogger(String key)
Specified by:
getLogger in interface LoggerFactory

getLogger

public Logger getLogger(String key,
                        String resourceBundleName)
Specified by:
getLogger in interface LoggerFactory

getResourceBundleName

public String getResourceBundleName()
Specified by:
getResourceBundleName in interface LoggerFactory

setResourceBundleName

public void setResourceBundleName(String resourceBundleName)
Specified by:
setResourceBundleName in interface LoggerFactory

getLoggers

public Logger[] getLoggers()
Specified by:
getLoggers in interface LoggerFactory

getTopicPrefix

public String getTopicPrefix()
Specified by:
getTopicPrefix in interface LoggerFactory

setIntLevel

public void setIntLevel(int l)
Sets the IntLevel attribute of the LoggerImpl object

Specified by:
setIntLevel in interface Logger
Parameters:
l - The new IntLevel value

setLevel

public void setLevel(Level l)
Sets the Level attribute of the LoggerImpl object

Specified by:
setLevel in interface Logger
Parameters:
l - The new Level value

getCurrentIntLevel

public int getCurrentIntLevel()
Gets the CurrentIntLevel attribute of the LoggerImpl object

Specified by:
getCurrentIntLevel in interface Logger
Returns:
The CurrentIntLevel value

getCurrentLevel

public Level getCurrentLevel()
Gets the CurrentLevel attribute of the LoggerImpl object

Specified by:
getCurrentLevel in interface Logger
Returns:
The CurrentLevel value

isLoggable

public boolean isLoggable(int l)
Gets the Loggable attribute of the LoggerImpl object

Specified by:
isLoggable in interface Logger
Parameters:
l - Description of Parameter
Returns:
The Loggable value

isLoggable

public boolean isLoggable(Level l)
Gets the Loggable attribute of the LoggerImpl object

Specified by:
isLoggable in interface Logger
Parameters:
l - Description of Parameter
Returns:
The Loggable value

isOn

public boolean isOn()
Gets the On attribute of the LoggerImpl object

Specified by:
isOn in interface Logger
Returns:
The On value

getTopics

public Enumeration getTopics()
Gets the Topics attribute of the LoggerImpl object

Specified by:
getTopics in interface TopicalLogger
Returns:
The Topics value

log

public void log(int level,
                Object o)
Log method

Specified by:
log in interface Logger

log

public void log(Level l,
                Object o)
Log method

Specified by:
log in interface Logger

log

public void log(int level,
                Object o,
                Throwable t)
Log method

Specified by:
log in interface Logger

log

public void log(Level l,
                Object o,
                Throwable t)
Log method

Specified by:
log in interface Logger

log

public void log(int level,
                Object o,
                Object location,
                Object method)
Log method

Specified by:
log in interface Logger

log

public void log(Level l,
                Object o,
                Object location,
                Object method)
Log method

Specified by:
log in interface Logger

log

public void log(int level,
                Object o,
                Throwable t,
                Object location,
                Object method)
Log method

Specified by:
log in interface Logger

log

public void log(Level l,
                Object o,
                Throwable t,
                Object location,
                Object method)
Log method

Specified by:
log in interface Logger

turnOn

public void turnOn()
Turn on this logger

Specified by:
turnOn in interface Logger

turnOff

public void turnOff()
Turn off this logger

Specified by:
turnOff in interface Logger

toString

public String toString()
The toString method is override to signal the logger imlementation fowards its messages to a printwriter

Overrides:
toString in class Object

addHandler

public void addHandler(Handler h)
                throws Exception
Specified by:
addHandler in interface TopicalLogger
Throws:
Exception

addTopic

public void addTopic(String topic)
              throws Exception
Specified by:
addTopic in interface TopicalLogger
Throws:
Exception

removeHandler

public void removeHandler(Handler h)
                   throws Exception
Specified by:
removeHandler in interface TopicalLogger
Throws:
Exception

removeAllHandlers

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

removeTopic

public void removeTopic(String topic)
                 throws Exception
Specified by:
removeTopic in interface TopicalLogger
Throws:
Exception

setAdditivity

public void setAdditivity(boolean a)
Specified by:
setAdditivity in interface TopicalLogger

getAdditivity

public boolean getAdditivity()
Specified by:
getAdditivity in interface TopicalLogger

getHandler

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

getHandler

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

getTopic

public String[] getTopic()
Specified by:
getTopic in interface TopicalLogger

getName

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

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

format

public static String format(String msg,
                            int removeTopStack)
This method permits to format messages. More exatcly this method find the class name and the method name where the log call was done. In order to find the right class name and method name, this method is parametrable either the number of call done in this logger.


addLogInfo

public void addLogInfo(Character pattern,
                       LogInfo logInfoProvider)
Set the extension

Specified by:
addLogInfo in interface MonologFactory

removeLogInfo

public void removeLogInfo(char pattern)
Remove an extension

Specified by:
removeLogInfo in interface MonologFactory
Parameters:
pattern - log info pattern

getLogInfo

public LogInfo getLogInfo(Character pattern)
Gets the provider of the extension

Specified by:
getLogInfo in interface MonologFactory
Parameters:
pattern -
Returns:
LogInfo provider


Copyright © 2012 OW2 Consortium. All Rights Reserved.