logahawk.formatters
Class StandardMessageFormatter
java.lang.Object
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.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
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.
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 DateFormat
s are not
inherently thread safe.
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.