|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.cocoon.util.log.ExtensiblePatternFormatter
A refactoring of org.apache.log.format.PatternFormatter
that
can be extended.
This formater formats the LogEntries according to a input pattern string.
The format of each pattern element can be %[+|-]#.#{field:subformat}
The +|- indicates left or right justify.
The #.# indicates the minimum and maximum size of output.
'field' indicates which field is to be output and must be one of
properties of LogEvent
'subformat' indicates a particular subformat and is currently unused.
Nested Class Summary | |
protected static class |
ExtensiblePatternFormatter.PatternRun
|
Field Summary | |
protected ExtensiblePatternFormatter.PatternRun[] |
m_formatSpecification
|
protected static int |
MAX_TYPE
The maximum value used for TYPEs. |
protected static int |
TYPE_CATEGORY
|
protected static String |
TYPE_CATEGORY_STR
|
protected static int |
TYPE_MESSAGE
|
protected static String |
TYPE_MESSAGE_STR
|
protected static int |
TYPE_PRIORITY
|
protected static String |
TYPE_PRIORITY_STR
|
protected static int |
TYPE_RELATIVE_TIME
|
protected static String |
TYPE_RELATIVE_TIME_STR
|
protected static int |
TYPE_TEXT
|
protected static int |
TYPE_THROWABLE
|
protected static String |
TYPE_THROWABLE_STR
|
protected static int |
TYPE_TIME
|
protected static String |
TYPE_TIME_STR
|
Constructor Summary | |
ExtensiblePatternFormatter()
|
Method Summary | |
protected int |
addPatternRun(Stack stack,
char[] pattern,
int index)
Extract and build a pattern from input string. |
protected int |
addTextRun(Stack stack,
char[] pattern,
int index)
Extract and build a text run from input string. |
protected void |
append(StringBuffer sb,
int minSize,
int maxSize,
boolean rightJustify,
String output)
Utility to append a string to buffer given certain constraints. |
protected String |
fix(String context)
Correct a context string by replacing '.'' |
String |
format(org.apache.log.LogEvent event)
Format the event according to the pattern. |
protected String |
formatPatternRun(org.apache.log.LogEvent event,
ExtensiblePatternFormatter.PatternRun run)
Formats a single pattern run (can be extended in subclasses). |
protected String |
getCategory(String category,
String format)
Utility method to format category. |
protected String |
getMessage(String message,
String format)
Utility method to format message. |
protected String |
getPriority(org.apache.log.Priority priority,
String format)
Get formatted priority string. |
protected String |
getStackTrace(Throwable throwable,
String format)
Utility method to format stack trace. |
protected String |
getTime(long time,
String format)
Utility method to format time. |
protected int |
getTypeIdFor(String type)
Retrieve the type-id for a particular string. |
protected void |
parse(String patternString)
Parse the input pattern and build internal data structures. |
void |
setFormat(String format)
Set the string description that the format is extracted from. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static final int TYPE_TEXT
protected static final int TYPE_CATEGORY
protected static final int TYPE_MESSAGE
protected static final int TYPE_TIME
protected static final int TYPE_RELATIVE_TIME
protected static final int TYPE_THROWABLE
protected static final int TYPE_PRIORITY
protected static final int MAX_TYPE
MAX_TYPE + 1
.
protected static final String TYPE_CATEGORY_STR
protected static final String TYPE_MESSAGE_STR
protected static final String TYPE_TIME_STR
protected static final String TYPE_RELATIVE_TIME_STR
protected static final String TYPE_THROWABLE_STR
protected static final String TYPE_PRIORITY_STR
protected ExtensiblePatternFormatter.PatternRun[] m_formatSpecification
Constructor Detail |
public ExtensiblePatternFormatter()
Method Detail |
protected int addPatternRun(Stack stack, char[] pattern, int index)
stack
- the stack on which to place patternspattern
- the input stringindex
- the start of pattern run
protected int addTextRun(Stack stack, char[] pattern, int index)
stack
- the stack on which to place runspattern
- the input stringindex
- the start of the text run
protected void append(StringBuffer sb, int minSize, int maxSize, boolean rightJustify, String output)
sb
- the StringBufferminSize
- the minimum size of output (0 to ignore)maxSize
- the maximum size of output (0 to ignore)rightJustify
- true if the string is to be right justified in it's box.output
- the input stringpublic String format(org.apache.log.LogEvent event)
format
in interface org.apache.log.format.Formatter
event
- the event
protected String formatPatternRun(org.apache.log.LogEvent event, ExtensiblePatternFormatter.PatternRun run)
run
- the pattern run to format.
protected String getCategory(String category, String format)
category
- the category stringformat
- ancilliary format parameter - allowed to be null
protected String getPriority(org.apache.log.Priority priority, String format)
protected final String fix(String context)
context
- the un-fixed context
protected String getMessage(String message, String format)
message
- the message stringformat
- ancilliary format parameter - allowed to be null
protected String getStackTrace(Throwable throwable, String format)
throwable
- the throwable instanceformat
- ancilliary format parameter - allowed to be null
protected String getTime(long time, String format)
time
- the timeformat
- ancilliary format parameter - allowed to be null
protected int getTypeIdFor(String type)
type
- the string
protected void parse(String patternString)
patternString
- the patternpublic void setFormat(String format)
format
- the string format
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |