org.jboss.test.logging.jdk
Class PatternFormatter

java.lang.Object
  extended by java.util.logging.Formatter
      extended by org.jboss.test.logging.jdk.PatternFormatter

public class PatternFormatter
extends Formatter

A log4j style pattern formatter.

Version:
$Revision: 1958 $
Author:
James P. Cakalic, Ceki Gülcü, Scott.Stark@jboss.org

Field Summary
protected  int BUF_SIZE
           
static String DEFAULT_CONVERSION_PATTERN
          Default pattern string for log output.
protected  int MAX_CAPACITY
           
static String TTCC_CONVERSION_PATTERN
          A conversion pattern equivalent to the TTCCCLayout.
 
Constructor Summary
PatternFormatter()
          Constructs a PatternLayout using the DEFAULT_LAYOUT_PATTERN.
PatternFormatter(String pattern)
          Constructs a PatternLayout using the supplied conversion pattern.
 
Method Summary
 void activateOptions()
          Does not do anything as options become effective
protected  PatternParser createPatternParser(String pattern)
          Returns PatternParser used to parse the conversion string.
 String format(LogRecord event)
          Produces a formatted string as specified by the conversion pattern.
 String getConversionPattern()
          Returns the value of the ConversionPattern option.
 boolean ignoresThrowable()
          The PatternLayout does not handle the throwable contained within LoggingEvents.
 void setConversionPattern(String conversionPattern)
          Set the ConversionPattern option.
 
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

DEFAULT_CONVERSION_PATTERN

public static final String DEFAULT_CONVERSION_PATTERN
Default pattern string for log output. Currently set to the string "%m%n" which just prints the application supplied message.

See Also:
Constant Field Values

TTCC_CONVERSION_PATTERN

public static final String TTCC_CONVERSION_PATTERN
A conversion pattern equivalent to the TTCCCLayout. Current value is %r [%t] %p %c %x - %m%n.

See Also:
Constant Field Values

BUF_SIZE

protected final int BUF_SIZE
See Also:
Constant Field Values

MAX_CAPACITY

protected final int MAX_CAPACITY
See Also:
Constant Field Values
Constructor Detail

PatternFormatter

public PatternFormatter()
Constructs a PatternLayout using the DEFAULT_LAYOUT_PATTERN.

The default pattern just produces the application supplied message.


PatternFormatter

public PatternFormatter(String pattern)
Constructs a PatternLayout using the supplied conversion pattern.

Parameters:
pattern - the pattern
Method Detail

setConversionPattern

public void setConversionPattern(String conversionPattern)
Set the ConversionPattern option. This is the string which controls formatting and consists of a mix of literal content and conversion specifiers.

Parameters:
conversionPattern - the conversion pattern

getConversionPattern

public String getConversionPattern()
Returns the value of the ConversionPattern option.

Returns:
the conversion pattern

activateOptions

public void activateOptions()
Does not do anything as options become effective


ignoresThrowable

public boolean ignoresThrowable()
The PatternLayout does not handle the throwable contained within LoggingEvents. Thus, it returns true.

Returns:
true if the throwable is ignored
Since:
0.8.4

createPatternParser

protected PatternParser createPatternParser(String pattern)
Returns PatternParser used to parse the conversion string. Subclasses may override this to return a subclass of PatternParser which recognize custom conversion characters.

Parameters:
pattern - the pattern
Returns:
the parser
Since:
0.9.0

format

public String format(LogRecord event)
Produces a formatted string as specified by the conversion pattern.

Specified by:
format in class Formatter


Copyright © 2010 JBoss, a division of Red Hat, Inc.. All Rights Reserved.