au.id.jericho.lib.html

Class WriterLogger

Implemented Interfaces:
Logger

public class WriterLogger
extends java.lang.Object
implements Logger

Provides an implementation of the Logger interface that sends output to the specified java.io.Writer.

Each log entry is formatted using the BasicLogFormatter.format(String level, String message, String loggerName) method.

Note that each logging level can be enabled independently in this implementation.

Constructor Summary

WriterLogger(Writer writer)
Constructs a new WriterLogger with the specified Writer and the default name.
WriterLogger(Writer writer, String name)
Constructs a new WriterLogger with the specified Writer and name.

Method Summary

void
debug(String message)
void
error(String message)
String
getName()
Returns the name of this logger.
Writer
getWriter()
Returns the Writer to which all output is sent.
void
info(String message)
boolean
isDebugEnabled()
boolean
isErrorEnabled()
boolean
isInfoEnabled()
boolean
isWarnEnabled()
void
setDebugEnabled(boolean debugEnabled)
Sets whether logging is enabled at the DEBUG level.
void
setErrorEnabled(boolean errorEnabled)
Sets whether logging is enabled at the ERROR level.
void
setInfoEnabled(boolean infoEnabled)
Sets whether logging is enabled at the INFO level.
void
setWarnEnabled(boolean warnEnabled)
Sets whether logging is enabled at the WARN level.
void
warn(String message)

Constructor Details

WriterLogger

public WriterLogger(Writer writer)
Constructs a new WriterLogger with the specified Writer and the default name.

The default logger name is "net.htmlparser.jericho".

Parameters:
writer - the Writer to which all output is sent.

WriterLogger

public WriterLogger(Writer writer,
                    String name)
Parameters:
writer - the Writer to which all output is sent.
name - the logger name, may be null.

Method Details

debug

public void debug(String message)
Specified by:
debug in interface Logger

error

public void error(String message)
Specified by:
error in interface Logger

getName

public String getName()
Returns the name of this logger.
Returns:
the name of this logger, may be null.

getWriter

public Writer getWriter()
Returns the Writer to which all output is sent.
Returns:
the Writer to which all output is sent.

info

public void info(String message)
Specified by:
info in interface Logger

isDebugEnabled

public boolean isDebugEnabled()
Specified by:
isDebugEnabled in interface Logger

isErrorEnabled

public boolean isErrorEnabled()
Specified by:
isErrorEnabled in interface Logger

isInfoEnabled

public boolean isInfoEnabled()
Specified by:
isInfoEnabled in interface Logger

isWarnEnabled

public boolean isWarnEnabled()
Specified by:
isWarnEnabled in interface Logger

setDebugEnabled

public void setDebugEnabled(boolean debugEnabled)
Sets whether logging is enabled at the DEBUG level.
Parameters:
debugEnabled - determines whether logging is enabled at the DEBUG level.

setErrorEnabled

public void setErrorEnabled(boolean errorEnabled)
Sets whether logging is enabled at the ERROR level.
Parameters:
errorEnabled - determines whether logging is enabled at the ERROR level.

setInfoEnabled

public void setInfoEnabled(boolean infoEnabled)
Sets whether logging is enabled at the INFO level.
Parameters:
infoEnabled - determines whether logging is enabled at the INFO level.

setWarnEnabled

public void setWarnEnabled(boolean warnEnabled)
Sets whether logging is enabled at the WARN level.
Parameters:
warnEnabled - determines whether logging is enabled at the WARN level.

warn

public void warn(String message)
Specified by:
warn in interface Logger