org.objectweb.util.monolog.wrapper.printwriter

Class LoggerImpl

Implemented Interfaces:
Handler, HandlerFactory, LevelFactory, Logger, LoggerFactory, MonologFactory, TopicalLogger

public class LoggerImpl
extends java.lang.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

static String
PRINT_WRITER
protected boolean
additivity
protected Hashtable
handlers
protected Map
levels
protected String
name
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, 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
addTopic(String topic)
void
configure(Properties prop)
Handler
createHandler(String hn, String handlertype)
Level
defineLevel(String name, String value)
Level
defineLevel(String name, int 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(String name)
Level
getLevel(int value)
This method is not synchronized because the configuration is rarely
Level[]
getLevels()
This method is not synchronized because the configuration is rarely
Logger
getLogger(String key)
Logger
getLogger(String key, String resourceBundleName)
Logger[]
getLoggers()
String
getName()
PrintWriter
getPrintWriter()
String
getResourceBundleName()
String[]
getTopic()
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()
Handler
removeHandler(String handlername)
void
removeHandler(Handler h)
void
removeLevel(String name)
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

Field Details

PRINT_WRITER

public static final String PRINT_WRITER


additivity

protected boolean additivity


handlers

protected Hashtable handlers


levels

protected Map levels


name

protected String name


topics

protected Vector topics

Constructor Details

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 Details

addHandler

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


addTopic

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


configure

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


createHandler

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


defineLevel

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


defineLevel

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


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.


getAdditivity

public boolean getAdditivity()
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()
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


getHandler

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


getHandler

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


getHandlers

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


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


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


getLoggers

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


getName

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


getPrintWriter

public PrintWriter getPrintWriter()


getResourceBundleName

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


getTopic

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


getTopics

public Enumeration getTopics()
Gets the Topics attribute of the LoggerImpl object
Specified by:
getTopics in interface TopicalLogger

Returns:
The Topics value


getType

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


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


log

public void log(int level,
                Object o)
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(int level,
                Object o,
                Throwable t)
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)
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(Level l,
                Object o,
                Throwable t)
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


removeAllHandlers

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


removeHandler

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


removeHandler

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


removeLevel

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


removeTopic

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


setAdditivity

public void setAdditivity(boolean a)
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)
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


setName

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


setResourceBundleName

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


toString

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


turnOff

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


turnOn

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