org.apache.log.format

Class ExtendedPatternFormatter

public class ExtendedPatternFormatter extends PatternFormatter

Formatter especially designed for debugging applications. This formatter extends the standard PatternFormatter to add two new possible expansions. These expansions are %{method} and %{thread}. In both cases the context map is first checked for values with specified key. This is to facilitate passing information about caller/thread when threads change (as in AsyncLogTarget). They then attempt to determine appropriate information dynamically.

Version: $Id: ExtendedPatternFormatter.java 30977 2004-07-30 03:57:54 -0500 (Fri, 30 Jul 2004) niclas $

Author: Avalon Development Team Peter Donald

Field Summary
intm_callStackOffset
static intTYPE_METHOD
static StringTYPE_METHOD_STR
static intTYPE_THREAD
static StringTYPE_THREAD_STR
Constructor Summary
ExtendedPatternFormatter(String format)
Creation of a new extended pattern formatter.
ExtendedPatternFormatter(String format, int callStackOffset)
Creation of a new extended pattern formatter.
Method Summary
protected StringformatPatternRun(LogEvent event, PatternRun run)
Formats a single pattern run (can be extended in subclasses).
StringgetMethod(LogEvent event)
Utility method to format category.
StringgetThread(LogEvent event)
Utility thread to format category.
protected intgetTypeIdFor(String type)
Retrieve the type-id for a particular string.

Field Detail

m_callStackOffset

private int m_callStackOffset

TYPE_METHOD

private static final int TYPE_METHOD

TYPE_METHOD_STR

private static final String TYPE_METHOD_STR

TYPE_THREAD

private static final int TYPE_THREAD

TYPE_THREAD_STR

private static final String TYPE_THREAD_STR

Constructor Detail

ExtendedPatternFormatter

public ExtendedPatternFormatter(String format)
Creation of a new extended pattern formatter.

Parameters: format the format string

ExtendedPatternFormatter

public ExtendedPatternFormatter(String format, int callStackOffset)
Creation of a new extended pattern formatter.

Parameters: format the format string callStackOffset the offset

Method Detail

formatPatternRun

protected String formatPatternRun(LogEvent event, PatternRun run)
Formats a single pattern run (can be extended in subclasses).

Parameters: event the log event run the pattern run to format.

Returns: the formatted result.

getMethod

private String getMethod(LogEvent event)
Utility method to format category.

Parameters: event the event

Returns: the formatted string

getThread

private String getThread(LogEvent event)
Utility thread to format category.

Parameters: event the even

Returns: the formatted string

getTypeIdFor

protected int getTypeIdFor(String type)
Retrieve the type-id for a particular string.

Parameters: type the string

Returns: the type-id