bb.util.logging
Class FormatterShort

java.lang.Object
  extended by java.util.logging.Formatter
      extended by bb.util.logging.FormatterShort

public class FormatterShort
extends Formatter

Like SimpleFormatter, this class uses only the essential information in a LogRecord in its output and is ideal for a ConsoleHandler to use. It differs in that it uses an even more abbreviated format, using just one line of text in most cases. See format for details.

This class is multithread safe: every public method which uses the non-multithread safe field hourFormat is synchronized.

Author:
Brent Boyer

Nested Class Summary
static class FormatterShort.UnitTest
          See the Overview page of the project's javadocs for a general description of this unit test class.
 
Field Summary
private static DateFormat hourFormat
           
private static String spacer
           
 
Constructor Summary
FormatterShort()
           
 
Method Summary
 String format(LogRecord record)
          Formats record into a String that looks like: -------------------------------------------------- level timeOfDay className.methodName [optional message, with any localization and param substitution applied] [optional Throwable; first line is its class name and message, followed by its stack trace] This format was chosen for two reasons.
 
Methods inherited from class java.util.logging.Formatter
formatMessage, getHead, getTail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

spacer

private static final String spacer
See Also:
Constant Field Values

hourFormat

private static final DateFormat hourFormat
Constructor Detail

FormatterShort

public FormatterShort()
Method Detail

format

public String format(LogRecord record)
              throws IllegalArgumentException
Formats record into a String that looks like:

 --------------------------------------------------
 level  timeOfDay  className.methodName  [optional message, with any localization and param substitution applied]
 [optional Throwable; first line is its class name and message, followed by its stack trace]
 

This format was chosen for two reasons. First, it contains the essential information. Second, uses only one line of text in the normal case (no Throwable).

Specified by:
format in class Formatter
Parameters:
record - the LogRecord to be formatted; must not be null
Returns:
a String representation of record
Throws:
IllegalArgumentException - if record == null