com.tenduke.diagnostics
Class ConsoleLogWriter

java.lang.Object
  extended by com.tenduke.diagnostics.AbstractLogWriter
      extended by com.tenduke.diagnostics.ConsoleLogWriter
All Implemented Interfaces:
LogEntrySubscriber

public class ConsoleLogWriter
extends AbstractLogWriter

Log writer that listens to log entries published by a Logger and writes error messages to console (stderr).

ConsoleLogWriter is derived from AbstractLogWriter, see AbstractLogWriter documentation for ConsoleLogWriter configurations.


Field Summary
 
Fields inherited from class com.tenduke.diagnostics.AbstractLogWriter
DEFAULT_DEBUG_LEVEL, DEFAULT_TEMPLATE_ERROR, DEFAULT_TEMPLATE_INFO, DEFAULT_TEMPLATE_WARNING
 
Constructor Summary
ConsoleLogWriter()
          Initializes new instance of the ConsoleLogWriter class.
 
Method Summary
protected  void printError(LogEntry entry, java.lang.Throwable throwable)
          Prints error in the case that printing log entry failed.
protected  void printLogEntry(LogEntry logEntry, java.lang.String formatTemplate)
          Prints log entry to log using the given format template.
 
Methods inherited from class com.tenduke.diagnostics.AbstractLogWriter
getDebugLevel, getLogEntryTemplateError, getLogEntryTemplateInfo, getLogEntryTemplateWarning, logEntryReceived, printLogEntry, setDebugLevel, setLogEntryTemplateError, setLogEntryTemplateInfo, setLogEntryTemplateWarning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConsoleLogWriter

public ConsoleLogWriter()
Initializes new instance of the ConsoleLogWriter class.

Method Detail

printError

protected void printError(LogEntry entry,
                          java.lang.Throwable throwable)
Prints error in the case that printing log entry failed.

Specified by:
printError in class AbstractLogWriter
Parameters:
entry - LogEntry for which writing failed.
throwable - The error that occurred when attempting to write.

printLogEntry

protected void printLogEntry(LogEntry logEntry,
                             java.lang.String formatTemplate)
                      throws java.io.IOException
Prints log entry to log using the given format template.

Specified by:
printLogEntry in class AbstractLogWriter
Parameters:
logEntry - LogEntry to write.
formatTemplate - Format template to use.
Throws:
java.io.IOException - Thrown if printing log entry fails.