consciouscode.logging
Class PrintLog

java.lang.Object
  extended by consciouscode.logging.AbstractLog
      extended by consciouscode.logging.PrintLog
All Implemented Interfaces:
Log
Direct Known Subclasses:
FileLog

public class PrintLog
extends AbstractLog

Log implementation that sends all messages to a PrintWriter. Messages may optionally be prefixed by a timestamp; this is configured by calling setTimestampPattern(java.lang.String).


Field Summary
 
Fields inherited from class consciouscode.logging.AbstractLog
DEBUG, ERROR, FATAL, INFO, myLogLevel, NONE, TRACE, WARN
 
Constructor Summary
PrintLog()
          Constructs a log that sends all messages to System.out.
PrintLog(PrintStream stream)
           
PrintLog(PrintWriter writer)
           
 
Method Summary
protected  void doLog(String message, Throwable exception)
           
 String getTimestampPattern()
          Get the pattern used to format message timestamps, or null if timestamps are not being logged.
 void setPrintWriter(PrintWriter writer)
          Replace the PrintWriter that receives logging messages.
 void setTimestampPattern(String pattern)
          Set the pattern used to format message timestamps.
 
Methods inherited from class consciouscode.logging.AbstractLog
debug, debug, doLog, error, error, fatal, fatal, info, info, isDebugEnabled, isErrorEnabled, isFatalEnabled, isInfoEnabled, isTraceEnabled, isWarnEnabled, setLogLevel, trace, trace, warn, warn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PrintLog

public PrintLog()
Constructs a log that sends all messages to System.out.


PrintLog

public PrintLog(PrintWriter writer)

PrintLog

public PrintLog(PrintStream stream)
Method Detail

setPrintWriter

public void setPrintWriter(PrintWriter writer)
Replace the PrintWriter that receives logging messages.


getTimestampPattern

public String getTimestampPattern()
Get the pattern used to format message timestamps, or null if timestamps are not being logged. By default, the pattern is null.


setTimestampPattern

public void setTimestampPattern(String pattern)
Set the pattern used to format message timestamps.

Parameters:
pattern - is a date-time format a specified by SimpleDateFormat. If null, no timestamp will be logged.

doLog

protected void doLog(String message,
                     Throwable exception)
Specified by:
doLog in class AbstractLog


Copyright © 2001–2012 Todd V. Jonker. All Rights Reserved.