|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--com.sap.tc.logging.Formatter
|
+--com.sap.tc.logging.TraceFormatter
Formats log records as readable lines.
| Constructor Summary | |
TraceFormatter()
Configures this trace formatter with the standard formatting pattern "%24d %-40l [%t] %s: %m". |
|
TraceFormatter(java.lang.String pattern)
Configures this trace formatter with a custom formatting pattern. |
|
| Method Summary | |
java.lang.String |
format(LogRecord rec)
Formats a log record which is then ready to be written to a log. |
java.lang.String |
getPattern()
Gets the current formatting pattern of this formatter. |
boolean |
isCompleteMessage(java.lang.String msg)
Determine if the message string reaches the valid end(delimiter) of a complete message record, according to the format defined by the formatter |
boolean |
isParsable()
Return true if this formatter supports message parsing formatted with this formatter. |
boolean |
isStartMessage(java.lang.String msg)
Determine if the message string has a valid start of message record |
LogRecord |
parseMsg(byte[] msgChunk)
|
LogRecord |
parseMsg(java.lang.String completeMsgData)
Message written with the specific formatter is read as plain string. |
void |
setPattern(java.lang.String pattern)
Configures this trace formatter with a custom formatting pattern. |
| Methods inherited from class com.sap.tc.logging.Formatter |
equals, getFooter, getFormatterName, getFormatterType, getHeader, isCompleteMessage, isStartMsg, setFormatterName |
| Methods inherited from class java.lang.Object |
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public TraceFormatter()
"%24d %-40l [%t] %s: %m".TraceFormatter(java.lang.String)public TraceFormatter(java.lang.String pattern)
setPattern(java.lang.String).pattern - Formatting patternTraceFormatter()| Method Detail |
public boolean isCompleteMessage(java.lang.String msg)
isCompleteMessage in class Formatterpublic boolean isParsable()
parseMsg(String).isParsable in class Formatterpublic boolean isStartMessage(java.lang.String msg)
isStartMessage in class Formatter
public LogRecord parseMsg(java.lang.String completeMsgData)
throws java.text.ParseException
Message written with the specific formatter is read as plain string. This method parses the content and massages the data into appropriate fields, into a LogRecord structure.
NOTE: UPDATE this method when newer version of format is defined by the formatter.
parseMsg in class FormatterA - complete message body and its admin data that can span across
multiple linesLogRecord. Return Null if formatter does not support
parsing.
public LogRecord parseMsg(byte[] msgChunk)
throws java.text.ParseException
parseMsg in class Formatterpublic java.lang.String getPattern()
setPattern(java.lang.String)public void setPattern(java.lang.String pattern)
Configures this trace formatter with a custom formatting pattern.
The pattern allows you to specify the message data fields, with place
holders of the form
"%[[-]<width>[-]]<type>",
interspersed with arbitrary text, that you want to have included in
formatted messages.
If you put a dash in front of the <width> of the field to be printed, which is a positive integral number, the field is aligned on the right, in case of a trailing dash it is aligned on the left. If you flank <width> with dashes on both sides, you get a centered field. If you omit the alignment, the field is left-aligned. The <type> that specifies the field can be one of
i the message identificationp the time stamp in milliseconds since January 1, 1970
00:00:00 GMTd the time stamp in readable formc the log controller the message was issued
througha the application on behalf of which the message was
issuedl the location of originu the user on behalf of which the message was issued
S the session on behalf of which the message was
issuedT the transaction on behalf of which the message was
issuedo the DSR (Distributed Statistics Record) component on
behalf of which the message was issued
e the DSR (Distributed Statistics Record) user on
behalf of which the message was issued
r the DSR (Distributed Statistics Record) transaction
on behalf of which the message was issued
t the thread that emitted the messageg the group indentations the message severitym the formatted message text%, insert a %%. With group
indentation, width is interpreted as the indentation for each level with
a standard value of 1, and alignment is ignored. As an
example, the standard pattern "%24d %-40l [%t] %s: %m"
lets the trace formatter print the date and time of the message in a
24-character column aligned to the left, followed by the right-aligned
location truncated from the left to 40 characters, the thread name in
brackets, and finally the severity name and the formatted message text
separated with a colon. A typical message would then look like this:
Place holders that do not match the above syntax are printed as is.May 11, 2001 11:17:42 AM ...g.TraceFormatterTest.testStdPattern() [main] Info: test standard pattern
pattern - Formatting patterngetPattern()public java.lang.String format(LogRecord rec)
Formatterformat in class Formattercom.sap.tc.logging.Formatterrec - Log record to be formatted
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||