Class WriterLogger
- All Implemented Interfaces:
Logger
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.
-
Constructor Summary
ConstructorsConstructorDescriptionWriterLogger
(Writer writer) Constructs a newWriterLogger
with the specifiedWriter
and the default name.WriterLogger
(Writer writer, String name) Constructs a newWriterLogger
with the specifiedWriter
and name. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Logs a message at the DEBUG level.void
Logs a message at the ERROR level.getName()
Returns the name of this logger.Returns theWriter
to which all output is sent.void
Logs a message at the INFO level.boolean
Indicates whether logging is enabled at the DEBUG level.boolean
Indicates whether logging is enabled at the ERROR level.boolean
Indicates whether logging is enabled at the INFO level.boolean
Indicates whether logging is enabled at the WARN level.protected void
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
Logs a message at the WARN level.
-
Constructor Details
-
WriterLogger
Constructs a newWriterLogger
with the specifiedWriter
and the default name.The default logger name is "
net.htmlparser.jericho
".- Parameters:
writer
- theWriter
to which all output is sent.
-
WriterLogger
Constructs a newWriterLogger
with the specifiedWriter
and name.The value of the
name
argument is only relevant if theBasicLogFormatter.OutputName
static property is set totrue
, otherwise the name is not included in the output at all.- Parameters:
writer
- theWriter
to which all output is sent.name
- the logger name, may benull
.
-
-
Method Details
-
getWriter
Returns theWriter
to which all output is sent.- Returns:
- the
Writer
to which all output is sent.
-
getName
Returns the name of this logger.- Returns:
- the name of this logger, may be
null
.
-
error
Description copied from interface:Logger
Logs a message at the ERROR level. -
warn
Description copied from interface:Logger
Logs a message at the WARN level. -
info
Description copied from interface:Logger
Logs a message at the INFO level. -
debug
Description copied from interface:Logger
Logs a message at the DEBUG level. -
isErrorEnabled
public boolean isErrorEnabled()Description copied from interface:Logger
Indicates whether logging is enabled at the ERROR level.- Specified by:
isErrorEnabled
in interfaceLogger
- Returns:
true
if logging is enabled at the ERROR level, otherwisefalse
.
-
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.
-
isWarnEnabled
public boolean isWarnEnabled()Description copied from interface:Logger
Indicates whether logging is enabled at the WARN level.- Specified by:
isWarnEnabled
in interfaceLogger
- Returns:
true
if logging is enabled at the WARN level, otherwisefalse
.
-
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.
-
isInfoEnabled
public boolean isInfoEnabled()Description copied from interface:Logger
Indicates whether logging is enabled at the INFO level.- Specified by:
isInfoEnabled
in interfaceLogger
- Returns:
true
if logging is enabled at the INFO level, otherwisefalse
.
-
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.
-
isDebugEnabled
public boolean isDebugEnabled()Description copied from interface:Logger
Indicates whether logging is enabled at the DEBUG level.- Specified by:
isDebugEnabled
in interfaceLogger
- Returns:
true
if logging is enabled at the DEBUG level, otherwisefalse
.
-
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.
-
log
Logs the specified message at the specified level.This method is called internally by the
error(String)
,warn(String)
,info(String)
anddebug(String)
methods, with thelevel
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 theWriter
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.- Parameters:
level
- a string representing the level of the log message.message
- the message to log.
-