platypus
Class LogFormatter

java.lang.Object
  extended by java.util.logging.Formatter
      extended by platypus.LogFormatter

public class LogFormatter
extends java.util.logging.Formatter

Creates a formatter for logging records. This format prints just the log message, preceded in the case of severe or warning errors by the words "Error: " or "Warning: " respectively. The date and time and the two-line format of the default Java console logger are thereby removed.

Author:
adapted from The Java Developers Almanac 1.4 (adaptation example e400). See: www.exampledepot.com/egs/java.util.logging/CustomFormat.html

Field Summary
private  Literals lits
          convenience variable for Literals access
 
Constructor Summary
LogFormatter()
           
 
Method Summary
 java.lang.String format(java.util.logging.LogRecord record)
          The principal function: it accepts a LogRecord and returns the string that should be written out by the logger.
 
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

lits

private final Literals lits
convenience variable for Literals access

Constructor Detail

LogFormatter

public LogFormatter()
Method Detail

format

public java.lang.String format(java.util.logging.LogRecord record)
The principal function: it accepts a LogRecord and returns the string that should be written out by the logger. It translates the Level.Severe status into an "Error" message and Level.Warning LogRecords into "Warning" messages.

Specified by:
format in class java.util.logging.Formatter
Parameters:
record - the LogRecord (which contains the severity and the string to log)
Returns:
the string to log. If null is passed in (an error), returns a newline.


Copyright © 2006-7 Pacific Data Works LLC