snaq.util.logging
Class TerseFormatter

java.lang.Object
  extended by java.util.logging.Formatter
      extended by java.util.logging.SimpleFormatter
          extended by snaq.util.logging.TerseFormatter
Direct Known Subclasses:
DBPoolLegacyFormatter

public class TerseFormatter
extends SimpleFormatter

Implementation of a simple single-line log Formatter for use with the Java Logging API. This is useful for producing terse log output, and can be used by setting the Formatter of a Handler to an instance of this class.

In a Java Logging configuration properties file:

     <handler>.formatter=snaq.util.logging.TerseFormatter
 

Author:
Giles Winstanley

Constructor Summary
TerseFormatter()
          Creates a new TerseFormatter instance (all details displayed).
TerseFormatter(boolean showClass, boolean showClassShort, boolean showMethod)
          Creates a new TerseFormatter instance.
TerseFormatter(boolean showLevel, boolean showClass, boolean showClassShort, boolean showMethod)
          Creates a new TerseFormatter instance.
 
Method Summary
 String format(LogRecord record)
           
 DateFormat getDateFormat()
           
 void setDateFormat(DateFormat df)
          Sets the DateFormat instance to use for formatting log entries.
 void setSeparator(String sep)
          Sets the separator string between the date and log message (default ": ").
 
Methods inherited from class java.util.logging.Formatter
formatMessage, getHead, getTail
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TerseFormatter

public TerseFormatter(boolean showLevel,
                      boolean showClass,
                      boolean showClassShort,
                      boolean showMethod)
Creates a new TerseFormatter instance.

Parameters:
showLevel - whether to display log levels
showClass - whether to display class names
showClassShort - whether to display short class names (i.e. no package details)
showMethod - whether to display method names

TerseFormatter

public TerseFormatter(boolean showClass,
                      boolean showClassShort,
                      boolean showMethod)
Creates a new TerseFormatter instance. The created instance displays log levels.

Parameters:
showClass - whether to display class names
showClassShort - whether to display short class names (i.e. no package details)
showMethod - whether to display method names

TerseFormatter

public TerseFormatter()
Creates a new TerseFormatter instance (all details displayed).

Method Detail

setDateFormat

public void setDateFormat(DateFormat df)
Sets the DateFormat instance to use for formatting log entries.

Parameters:
df - DateFormat instance to use

getDateFormat

public DateFormat getDateFormat()
Returns:
DateFormat instance used for formatting log entries.

setSeparator

public void setSeparator(String sep)
Sets the separator string between the date and log message (default ": "). To set the default separator (": "), call with a null argument.

Parameters:
sep - string to use as separator

format

public String format(LogRecord record)
Overrides:
format in class SimpleFormatter