au.id.jericho.lib.html
Class WriterLogger
java.lang.Object
au.id.jericho.lib.html.WriterLogger
- Logger
public class WriterLogger
extends java.lang.Object
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.
All levels are enabled by default.
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.
|
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()
|
protected void | log(String level, String message) - Logs the specified message at the specified level.
|
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)
|
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
".
writer
- the Writer
to which all output is sent.
WriterLogger
public WriterLogger(Writer writer,
String name)
Constructs a new
WriterLogger
with the specified
Writer
and name.
The value of the
name
argument is only relevant if the
BasicLogFormatter.OutputName
static property is set to
true
,
otherwise the name is not included in the output at all.
writer
- the Writer
to which all output is sent.name
- the logger name, may be null
.
debug
public void debug(String message)
- debug in interface Logger
error
public void error(String message)
- error in interface Logger
getName
public String getName()
Returns the name of this logger.
- the name of this logger, may be
null
.
getWriter
public Writer getWriter()
Returns the Writer
to which all output is sent.
- the
Writer
to which all output is sent.
info
public void info(String message)
- info in interface Logger
log
protected void log(String level,
String message)
Logs the specified message at the specified level.
This method is called internally by the
error(String)
,
warn(String)
,
info(String)
and
debug(String)
methods,
with the
level
argument set to the text "
ERROR
", "
WARN
", "
INFO
", or "
DEBUG
" respectively.
The default implementation of this method sends the the output of
BasicLogFormatter.format
(level,message,
getName()
)
to the
Writer
specified in the class constructor, and then flushes it.
Overriding this method in a subclass provides a convenient means of logging to a
Writer
using a different format.
level
- a string representing the level of the log message.message
- the message to log.
setDebugEnabled
public void setDebugEnabled(boolean debugEnabled)
Sets whether logging is enabled at the DEBUG level.
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.
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.
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.
warnEnabled
- determines whether logging is enabled at the WARN level.
warn
public void warn(String message)
- warn in interface Logger