logahawk.formatters
Class StandardMessageFormatter

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

@ThreadSafe
public class StandardMessageFormatter
extends Object
implements MessageFormatter

Provides the standard log formatting (default implementatons of LogMeta. The date is formatted using the provided DateFormat, and the total message format is "Date Severity: Message", where Severity is the fixed length string for severity. If there is no message "(null)" will be output.


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
StandardMessageFormatter()
          Sets addTrailingLineBreak to false, and dateFormat to DateArgFormatter.STD_DATE_FORMAT
StandardMessageFormatter(boolean addTrailingLineBreak)
           
StandardMessageFormatter(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

StandardMessageFormatter

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


StandardMessageFormatter

public StandardMessageFormatter(boolean addTrailingLineBreak)

StandardMessageFormatter

public StandardMessageFormatter(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. This is usually false when using another logging framework that will automatically add a line break for each message.