|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.tenduke.diagnostics.AbstractLogWriter
public abstract class AbstractLogWriter
Abstract base class for log writers that listen to log entries published by a Logger and write entries to a log (log file,
stdout / stderr etc.)
AbstractLogWriter uses getDebugLevel(boolean) with true input parameter as the highest debug level
of a received log entry
LogEntry.getDebugLevel() that is written to log. LogEntries with higher debug level are discarded.
AbstractLogWriter uses formatting templates to write each LogEntry to log. Templates can be specified for each
LogEntry.getEventType(). MessageFormat is used to write log entries using this templates. Supported format
specifiers are:
Table of configuration keys used by this class:
| Key name | Description | Default value |
|---|---|---|
| logging.logwriter.debug.level | Highest debug level value of received log entry that is written to log. Example: Debug level is set to 3, which means that any LogEntry with debug level set to 3 or less will be printed and LogEntry objects with debug level 4 and 5 will be omitted. |
N/A
|
| logging.logwriter.template.error |
Formatting template for log entries with event type com.tenduke.diagnostics.LogEntry.EventType.Error.
|
N/A
|
| logging.logwriter.template.warning |
Formatting template for log entries with event type com.tenduke.diagnostics.LogEntry.EventType.Warning.
|
N/A
|
| logging.logwriter.template.info |
Formatting template for log entries with event type com.tenduke.diagnostics.LogEntry.EventType.Info.
|
N/A
|
Table of JVM system properties defined by this class.
| System property | Description | Default value |
|---|---|---|
| logging.logwriter.debug.level | Highest debug level value of received log entry that is written to log. Example: Debug level is set to 3, which means that any LogEntry with debug level set to 3 or less will be printed and LogEntry objects with debug level 4 and 5 will be omitted. |
5
|
| logging.logwriter.template.error |
Formatting template for log entries with event type com.tenduke.diagnostics.LogEntry.EventType.Error.
|
N/A
|
| logging.logwriter.template.warning |
Formatting template for log entries with event type com.tenduke.diagnostics.LogEntry.EventType.Warning.
|
N/A
|
| logging.logwriter.template.info |
Formatting template for log entries with event type com.tenduke.diagnostics.LogEntry.EventType.Info.
|
N/A
|
| Field Summary | |
|---|---|
static int |
DEFAULT_DEBUG_LEVEL
Default debug level (5), if not defined in the main configuration file with a key 'logging.logwriter.debug.level'. |
static java.lang.String |
DEFAULT_TEMPLATE_ERROR
Default print template "{1}: {3}\n{5}" for LogEntry.EventType.Error, if not defined in the main configuration
file with a key 'logging.logwriter.template.error'. |
static java.lang.String |
DEFAULT_TEMPLATE_INFO
Default print template "{1}: {3}" for LogEntry.EventType.Info, if not defined in the main configuration
file with a key 'logging.logwriter.template.info'. |
static java.lang.String |
DEFAULT_TEMPLATE_WARNING
Default print template "{1}: {3}\n{4}" for LogEntry.EventType.Warning, if not defined in the main configuration
file with a key 'logging.logwriter.template.warning'. |
| Constructor Summary | |
|---|---|
protected |
AbstractLogWriter()
Initializes new instance of the AbstractLogWriter class. |
| Method Summary | |
|---|---|
java.lang.Integer |
getDebugLevel(boolean allowDefault)
Gets highest debug level of a received log entry LogEntry.getDebugLevel() that is written to log. |
java.lang.String |
getLogEntryTemplateError(boolean allowDefault)
Gets output formatting template for error log entries. |
java.lang.String |
getLogEntryTemplateInfo(boolean allowDefault)
Gets output formatting template for info log entries. |
java.lang.String |
getLogEntryTemplateWarning(boolean allowDefault)
Gets output formatting template for warning log entries. |
void |
logEntryReceived(LogEntry entry)
Method that is called for each LogEntrySubscriber by Logger when a new log entry is received. |
protected abstract void |
printError(LogEntry entry,
java.lang.Throwable throwable)
Prints error in the case that printing log entry failed. |
protected void |
printLogEntry(LogEntry logEntry)
Prints log entry to log. |
protected abstract void |
printLogEntry(LogEntry logEntry,
java.lang.String formatTemplate)
Prints log entry to log using the given format template. |
void |
setDebugLevel(java.lang.Integer debugLevel)
Sets highest debug level of a received log entry LogEntry.getDebugLevel() that is written to log. |
void |
setLogEntryTemplateError(java.lang.String logEntryTemplateError)
Sets output formatting template for error log entries. |
void |
setLogEntryTemplateInfo(java.lang.String logEntryTemplateInfo)
Sets output formatting template for info log entries. |
void |
setLogEntryTemplateWarning(java.lang.String logEntryTemplateWarning)
Sets output formatting template for warning log entries. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int DEFAULT_DEBUG_LEVEL
public static final java.lang.String DEFAULT_TEMPLATE_ERROR
LogEntry.EventType.Error, if not defined in the main configuration
file with a key 'logging.logwriter.template.error'.
public static final java.lang.String DEFAULT_TEMPLATE_INFO
LogEntry.EventType.Info, if not defined in the main configuration
file with a key 'logging.logwriter.template.info'.
public static final java.lang.String DEFAULT_TEMPLATE_WARNING
LogEntry.EventType.Warning, if not defined in the main configuration
file with a key 'logging.logwriter.template.warning'.
| Constructor Detail |
|---|
protected AbstractLogWriter()
| Method Detail |
|---|
public java.lang.Integer getDebugLevel(boolean allowDefault)
LogEntry.getDebugLevel() that is written to log.
allowDefault - If true, default debug level is returned if no debug level has been explicitly set.
public java.lang.String getLogEntryTemplateError(boolean allowDefault)
allowDefault - If true, default template is returned if no template has been explicitly set.
public java.lang.String getLogEntryTemplateInfo(boolean allowDefault)
allowDefault - If true, default template is returned if no template has been explicitly set.
public java.lang.String getLogEntryTemplateWarning(boolean allowDefault)
allowDefault - If true, default template is returned if no template has been explicitly set.
public void logEntryReceived(LogEntry entry)
logEntryReceived in interface LogEntrySubscriberentry - the log entry
protected abstract void printError(LogEntry entry,
java.lang.Throwable throwable)
entry - LogEntry for which writing failed.throwable - The error that occurred when attempting to write.
protected void printLogEntry(LogEntry logEntry)
throws java.io.IOException
printLogEntry(com.tenduke.diagnostics.LogEntry, java.lang.String).
logEntry - LogEntry to write.
java.io.IOException - Thrown if printing log entry to writer fails.
protected abstract void printLogEntry(LogEntry logEntry,
java.lang.String formatTemplate)
throws java.io.IOException
logEntry - LogEntry to write.formatTemplate - Format template to use.
java.io.IOException - Thrown if printing log entry fails.public void setDebugLevel(java.lang.Integer debugLevel)
LogEntry.getDebugLevel() that is written to log.
debugLevel - Highest debug level of a received LogEntry that is written to log. Debug level value 5 means that all
received log entries are written to log, 0 means that nothing is written.public void setLogEntryTemplateError(java.lang.String logEntryTemplateError)
logEntryTemplateError - Output formatting template for error log entries.public void setLogEntryTemplateInfo(java.lang.String logEntryTemplateInfo)
logEntryTemplateInfo - Output formatting template for info log entries.public void setLogEntryTemplateWarning(java.lang.String logEntryTemplateWarning)
logEntryTemplateWarning - Output formatting template for warning log entries.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||