logahawk.formatters
Class ThreadMessageFormatter

java.lang.Object
  extended by logahawk.formatters.ThreadMessageFormatter
All Implemented Interfaces:
MessageFormatter

public class ThreadMessageFormatter
extends Object
implements MessageFormatter

Provides the log formatting of ThreadLogMeta, very similar to StandardMessageFormatter. The format is "Date [ThreadID-ThreadName] Severity: Message"


Field Summary
protected  boolean addTrailingLineBreak
           
protected  StringBuilder buffer
          A single StringBuilder is used to avoid having to re-allocate a string each time.
protected  DateFormat dateFormat
           
 
Constructor Summary
ThreadMessageFormatter()
          Sets addTrailingLineBreak to false, and dateFormat to DateArgFormatter.STD_DATE_FORMAT
ThreadMessageFormatter(DateFormat dateFormat, boolean addTrailingLineBreak)
           
 
Method Summary
 String format(LogMeta meta, String message)
           
 boolean getAddTrailingLineBreak()
          Returns true if the formatter will append a trailing line break.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

addTrailingLineBreak

protected final boolean addTrailingLineBreak

dateFormat

protected DateFormat dateFormat

buffer

protected final StringBuilder buffer
A single StringBuilder is used to avoid having to re-allocate a string each time.

Constructor Detail

ThreadMessageFormatter

public ThreadMessageFormatter()
Sets addTrailingLineBreak to false, and dateFormat to DateArgFormatter.STD_DATE_FORMAT


ThreadMessageFormatter

public ThreadMessageFormatter(DateFormat dateFormat,
                              boolean addTrailingLineBreak)
Parameters:
dateFormat - A clone of this DateFormat will be created (because DateFormats are not inherently thread safe.
Method Detail

format

public String format(LogMeta meta,
                     String message)
Specified by:
format in interface MessageFormatter

getAddTrailingLineBreak

public boolean getAddTrailingLineBreak()
Returns true if the formatter will append a trailing line break. By default this is false.