com.bristle.javalib.log
Class Logger.WriterLoggerTarget

java.lang.Object
  extended by com.bristle.javalib.log.Logger.WriterLoggerTarget
All Implemented Interfaces:
Logger.LoggerTarget
Enclosing class:
Logger

public static class Logger.WriterLoggerTarget
extends Object
implements Logger.LoggerTarget

This class implements the LoggerTarget interface, writing log entries to a Writer. It is a simple example of a LoggerTarget that is used by the Tester class below, and can also be used by clients outside of the Logger class.


Constructor Summary
Logger.WriterLoggerTarget(Writer writer)
          Constructor.
 
Method Summary
 boolean getShowDynamicFields()
          Get the flag about whether to show dynamic fields, like memory sizes and time stamps.
 Writer getWriter()
          Get the Writer that messages are currently being logged to.
 void log(Logger.Entry entry)
          Log the log entry to the Writer.
 void setShowDynamicFields(boolean blnVal)
          Set the flag about whether to show dynamic fields, like memory sizes and time stamps.
 void setWriter(Writer writer)
          Set the Writer to write log entries to.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Logger.WriterLoggerTarget

public Logger.WriterLoggerTarget(Writer writer)
Constructor.

Parameters:
writer - The Writer to write log entries to.
Method Detail

setWriter

public void setWriter(Writer writer)
Set the Writer to write log entries to. If null, no logging to a Writer is performed.

Parameters:
writer - The new Writer.

getWriter

public Writer getWriter()
Get the Writer that messages are currently being logged to.

Returns:
The Writer.

setShowDynamicFields

public void setShowDynamicFields(boolean blnVal)
Set the flag about whether to show dynamic fields, like memory sizes and time stamps. It is useful to turn these fields off if you are planning to compare the results with a previously captured set of results, and don't really care about the values of the dynamic fields.

Parameters:
blnVal - The new value.

getShowDynamicFields

public boolean getShowDynamicFields()
Get the flag about whether to show dynamic fields, like memory sizes and time stamps.

Returns:
The value of the flag.

log

public void log(Logger.Entry entry)
         throws IOException
Log the log entry to the Writer.

Specified by:
log in interface Logger.LoggerTarget
Parameters:
entry - The log entry to write to the log.
Throws:
IOException - When an error occurs writing to the Writer.