momelog
Class Formatter

java.lang.Object
  extended by momelog.Formatter
Direct Known Subclasses:
PatternFormatter

public abstract class Formatter
extends Object

Abstract class that every class intended to format logging events should extend. Contains three methods to convert LogEvent instance to String or other object.

Formatter class extending Formatter can override just the abstract format(LogEvent, StringBuffer) method or all methods of this class.

Version:
1.0
Author:
Sergio Morozov

Constructor Summary
Formatter()
           
 
Method Summary
 String format(LogEvent event)
          Converts given logging event to String.
abstract  void format(LogEvent event, StringBuffer buffer)
          Abstract method intended to convert specified logging event to string and append it to the given StringBuffer.
 Object formatAsObject(LogEvent event)
          General method intended to convert given logging event to Object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Formatter

public Formatter()
Method Detail

format

public abstract void format(LogEvent event,
                            StringBuffer buffer)
Abstract method intended to convert specified logging event to string and append it to the given StringBuffer. Formatter implementation should override this method and provide needed conversion mechanism.

Parameters:
event - LogEvent instance to convert.
buffer - StringBuffer where to append formatted string.
Since:
1.0

format

public String format(LogEvent event)
Converts given logging event to String. Implementation of this method makes use of format(LogEvent, StringBuffer) method. Formatter implementation can override this method to change it's functionality.

Parameters:
event - LogEvent instance to convert.
Returns:
formatted string.
Since:
1.0

formatAsObject

public Object formatAsObject(LogEvent event)
General method intended to convert given logging event to Object. Implementation of this method returns formatted string as format(LogEvent) method does. Formatter implementation can override this method to change it's functionality.

Parameters:
event - LogEvent instance to convert.
Returns:
formatted logging event as Object.
Since:
1.0