|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jcoderz.commons.logging.LogLineFormat
public abstract class LogLineFormat
This is the base class for various log line formats. It gives the defined types of log lines and a common interface for formatting and parsing different types of log lines.
| Nested Class Summary | |
|---|---|
static class |
LogLineFormat.LogLineType
This helper class is used as type safe enumeration for all defined log line types. |
| Field Summary | |
|---|---|
protected static Format[] |
EMPTY_FORMATTERS
|
static LogLineFormat.LogLineType |
ERROR_MESSAGE
Used for Loggable logs carrying a Throwable or being derived from a Throwable. |
static LogLineFormat.LogLineType |
EXCEPTION_MESSAGE
Used for standard LogRecord logs carrying a Throwable. |
static LogLineFormat.LogLineType |
LOG_MESSAGE
Used for Loggable logs. |
static LogLineFormat.LogLineType |
NESTED_MESSAGE
Used for nested loggables. |
static LogLineFormat.LogLineType |
PARAMETER_LINE
Used for logging parameters as name and value list. |
protected static int |
SOURCECLASS_INDEX
Index for source class name within String array as it is returned by getLogSource(String). |
protected static int |
SOURCEMETHOD_INDEX
Index for source method name within String array as it is returned by getLogSource(String). |
static LogLineFormat.LogLineType |
STACKTRACE_MESSAGE
Used for stack trace elements of logged Throwables. |
static LogLineFormat.LogLineType |
TRACE_MESSAGE
Used for standard LogRecord logs. |
| Constructor Summary | |
|---|---|
protected |
LogLineFormat(LogLineFormat.LogLineType type,
MessageFormat format,
int numberOfArguments)
Creates and initializes a new instance of this. |
| Method Summary | |
|---|---|
protected void |
format(StringBuffer sb)
Formats all parameters set so far into the supplied StringBuffer using the encapsulated MessageFormat. |
abstract void |
format(StringBuffer sb,
LogRecord record,
Loggable loggable,
List trackingIdSequence,
Throwable thrown,
Object parameter)
The common interface for all log line formatters. |
protected static Format |
getBusinessImpactFormat()
Gets the format to use for formatting the business impact element. |
protected static Format |
getCategoryFormat()
Gets the format to use for formatting the category element. |
protected static Format |
getInstanceIdFormat()
Gets the format to use for formatting an instance id element. |
protected static Format |
getLoggerLevelFormat()
Gets the format to use for formatting the logger /severity level element. |
static LogLineFormat.LogLineType |
getLogLineType(char code)
Gets the LogLineType matching the supplied code. |
protected String[] |
getLogSource(String source)
Gets the source class name and source method name where the Log record was logged from the supplied string. |
protected static Format |
getMessageSymbolFormat()
Gets the format to use for formatting a symbol id element. |
protected static Format |
getNodeIdFormat()
Gets the format to use for formatting a node id element. |
protected Object |
getParameter(int index)
Gets the parameter at the specified position. |
protected static Format |
getThreadIdFormat()
Gets the format to use for formatting a thread id element. |
protected static Format |
getThreadNameFormat()
Gets the format to use for formatting the thread name element. |
protected static Format |
getTimestampFormat()
Gets the format to use for formatting a timestamp element. |
protected static Format |
getTrackingNumberFormat()
Gets the format to use for formatting the tracking numbers |
protected void |
parse(StringBuffer sb)
Parses the supplied StringBuffer from beginning to end with the encapsulated MessageFormat. |
abstract void |
parse(StringBuffer sb,
LogFileEntry entry)
The common interface for all log line formatters. |
protected void |
setFormats(Format[] formats)
Sets the contributing formats for the encapsulated MessageFormat. |
protected void |
setParameter(int index,
Object obj)
Sets a parameter at the specified position to be used when formatting. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final LogLineFormat.LogLineType TRACE_MESSAGE
public static final LogLineFormat.LogLineType EXCEPTION_MESSAGE
public static final LogLineFormat.LogLineType LOG_MESSAGE
public static final LogLineFormat.LogLineType ERROR_MESSAGE
public static final LogLineFormat.LogLineType NESTED_MESSAGE
public static final LogLineFormat.LogLineType STACKTRACE_MESSAGE
public static final LogLineFormat.LogLineType PARAMETER_LINE
protected static final Format[] EMPTY_FORMATTERS
protected static final int SOURCECLASS_INDEX
protected static final int SOURCEMETHOD_INDEX
| Constructor Detail |
|---|
protected LogLineFormat(LogLineFormat.LogLineType type,
MessageFormat format,
int numberOfArguments)
type - The type of this.format - The MessageFormat used for formatting and parsing a log line
of this type.numberOfArguments - The number of arguments for the supplied message
format.| Method Detail |
|---|
public abstract void format(StringBuffer sb,
LogRecord record,
Loggable loggable,
List trackingIdSequence,
Throwable thrown,
Object parameter)
sb - The StringBuffer where to append the formatted data.record - THe LogRecord to format.loggable - The Loggable to format.trackingIdSequence - The sequence of contributing tracking ids.thrown - The Throwable to format.parameter - An additional parameter, which might be required for
an implementation of this.
public abstract void parse(StringBuffer sb,
LogFileEntry entry)
throws ParseException
sb - The StringBuffer containing the log line to parse from the
current position to the end.entry - The LogFileEntry which gets the data being parsed.
ParseException - if an error occurs parsing the log line.
public static LogLineFormat.LogLineType getLogLineType(char code)
throws IllegalArgumentException
code - The code for the LogLineType to return.
code.
IllegalArgumentException - if no such LogLineType.protected final void setFormats(Format[] formats)
formats - The formats to set.
protected final void setParameter(int index,
Object obj)
index - The index at which to set the parameter. It must hold true
0 <= index < num parameters with num parameter being the
number set when creating this.obj - The object to set at the supplied position.protected final Object getParameter(int index)
index - The index from which to get the parameter. It must hold true
0 <= index < num parameters with num parameter being the
number set when creating this.
protected final void format(StringBuffer sb)
sb - The StringBuffer into which to format the data.
protected final void parse(StringBuffer sb)
throws ParseException
sb - The StringBuffer from which to parse the parameter values.
ParseException - if an error occurs parsing the string.protected static final Format getThreadIdFormat()
protected static final Format getTimestampFormat()
protected static final Format getNodeIdFormat()
protected static final Format getInstanceIdFormat()
protected static final Format getLoggerLevelFormat()
protected static final Format getMessageSymbolFormat()
protected static final Format getBusinessImpactFormat()
protected static final Format getCategoryFormat()
protected static final Format getThreadNameFormat()
protected static final Format getTrackingNumberFormat()
protected final String[] getLogSource(String source)
source - the log source in format classname.methodname
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||