Package com.tibco.patterns.qbp
Class QBPFileLogger
- java.lang.Object
-
- com.tibco.patterns.qbp.AQBPLogger
-
- com.tibco.patterns.qbp.QBPFileLogger
-
public class QBPFileLogger extends AQBPLogger
An implementation of AQBPLogger that logs to a standard file or stream. This logs to either a file system file or to a given PrintStream. The log messages are on separate lines, each log message having the format:time-stamp level 'message [reason]'
Where:
time-stamp is a time stamp with the format:
[yyyy-MM-ddTHH-mm-ss.SSS]
This records the time the log call was made.level is the log level. It is one of:
- ERROR
- CONFIG_ERROR
- WARNING
- INFO
- TRACE
message is the log message.
reason is included only if a throwable reason object was included in the log call. It has the format:
Reason: 'throwable-message'
where throwable-message is the message from the reason object.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.tibco.patterns.qbp.AQBPLogger
AQBPLogger.LogLevel, AQBPLogger.QBPConfigException, AQBPLogger.QBPException
-
-
Constructor Summary
Constructors Constructor Description QBPFileLogger(java.io.File log_file)Create a logger that logs to the given file.QBPFileLogger(java.io.PrintStream log_stream)Log to an existing stream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close the logger.protected java.lang.StringsendConfigError(java.lang.String raw_msg)Format a configuration error message and send it to the log.protected java.lang.StringsendConfigError(java.lang.String raw_msg, java.lang.Throwable reason)Format a configuration error message and send it to the log with a reason.protected java.lang.StringsendError(java.lang.String raw_msg)Format an error message and send it to the log.protected java.lang.StringsendError(java.lang.String raw_msg, java.lang.Throwable reason)Format an error message and send it to the log with a reason.protected java.lang.StringsendInfo(java.lang.String raw_msg)Format an information message and send it to the log.protected java.lang.StringsendTrace(java.lang.String raw_msg)Format a Trace message and send it to the log.protected java.lang.StringsendWarning(java.lang.String raw_msg)Format a warning message and send it to the log.protected java.lang.StringsendWarning(java.lang.String raw_msg, java.lang.Throwable reason)Format a warning message with a reason and send it to the log.-
Methods inherited from class com.tibco.patterns.qbp.AQBPLogger
getConfigNoteCount, isConfigExceptionModeOn, isStandardExceptionModeOn, logConfigError, logConfigError, logConfigFatal, logConfigFatal, logError, logError, logFatal, logFatal, logInfo, logTrace, logWarning, logWarning, newConfigFatal, newConfigFatal, newFatal, newFatal, popConfig, pushConfig, setConfig, setEnabledLevels, turnOffConfigExceptionMode, turnOffConfigNotes, turnOffStandardExceptionMode, turnOnConfigExceptionMode, turnOnConfigNotes, turnOnStandardExceptionMode
-
-
-
-
Constructor Detail
-
QBPFileLogger
public QBPFileLogger(java.io.File log_file) throws java.lang.IllegalArgumentExceptionCreate a logger that logs to the given file. If the file already exists log messages are appended to the end. If it does not exist it is created.- Parameters:
log_file- log messages are appended to this file.- Throws:
java.lang.IllegalArgumentException- if could not create or open for writting this file for any reason.
-
QBPFileLogger
public QBPFileLogger(java.io.PrintStream log_stream)
Log to an existing stream. Create a logger that logs messages to an existing, open stream.Caution! If other data is being written to the stream log messages could be lost. Write operations are synchronized on the given stream, but the logger cannot enforce others to also synchronize on the stream.
The close method of this object will not close the given stream.
- Parameters:
log_stream- the stream for all log messages.
-
-
Method Detail
-
close
public void close()
Close the logger. This closes the stream to the log file, if the stream was opened by this logger. All log attempts after this call will fail, regardless of whether the stream was closed or not.
-
sendError
protected java.lang.String sendError(java.lang.String raw_msg)
Format an error message and send it to the log. This formats a raw error message and sends it to the error log. It returns the formatted message. The time stamp can be used to link the message in the log to any thrown exception or notation including the message.- Specified by:
sendErrorin classAQBPLogger- Parameters:
raw_msg- the error message.- Returns:
- the formatted error message. If there is a failure sending the log message null should be returned; this triggers a thrown exception.
-
sendError
protected java.lang.String sendError(java.lang.String raw_msg, java.lang.Throwable reason)Format an error message and send it to the log with a reason. This formats a raw error message and sends it to the error log. A throwable object that triggered the exception is included. It returns the formatted message. The time stamp can be used to link the message in the log to any thrown exception or notation including the message.- Specified by:
sendErrorin classAQBPLogger- Parameters:
raw_msg- the error message.reason- the thrown exception that triggered this call.- Returns:
- the formatted error message. If there is a failure sending the log message null should be returned, this will trigger a thrown exception.
-
sendConfigError
protected java.lang.String sendConfigError(java.lang.String raw_msg)
Format a configuration error message and send it to the log. This formats a raw error message and sends it to the error log. It returns the formatted message. The time stamp can be used to link the message in the log to any thrown exception or notation including the message.- Specified by:
sendConfigErrorin classAQBPLogger- Parameters:
raw_msg- the error message.- Returns:
- the formatted error message. If there is a failure sending the log message null should be returned, this will trigger a thrown exception.
-
sendConfigError
protected java.lang.String sendConfigError(java.lang.String raw_msg, java.lang.Throwable reason)Format a configuration error message and send it to the log with a reason. This formats a raw error message and sends it to the error log. A throwable object that triggered the exception is included. It returns the formatted message. The time stamp can be used to link the message in the log to any thrown exception or notation including the message.- Specified by:
sendConfigErrorin classAQBPLogger- Parameters:
raw_msg- the error message.reason- the thrown exception that triggered this call.- Returns:
- the formatted error message. If there is a failure sending the log message null should be returned, this will trigger a thrown exception.
-
sendWarning
protected java.lang.String sendWarning(java.lang.String raw_msg)
Format a warning message and send it to the log. This formats a raw warning message and sends it to the warning log. It returns the formatted message. The time stamp can be used to link the message in the log to any thrown exception or notation including the message. (Note: currently warnings do not trigger exceptions or notations, but may in the future.)- Specified by:
sendWarningin classAQBPLogger- Parameters:
raw_msg- the error message.- Returns:
- the formatted warning message. If there is a failure sending the log message null should be returned.
-
sendWarning
protected java.lang.String sendWarning(java.lang.String raw_msg, java.lang.Throwable reason)Format a warning message with a reason and send it to the log. This formats a raw warning message along with a throwable object that triggered the warning, and sends it to the warning log. It returns the formatted message. The time stamp can be used to link the message in the log to any thrown exception or notation including the message. (Note: currently warnings do not trigger exceptions or notations, but may in the future.)- Specified by:
sendWarningin classAQBPLogger- Parameters:
raw_msg- the error message.reason- the thrown exception that triggered this call.- Returns:
- the formatted warning message. If there is a failure sending the log message null should be returned.
-
sendInfo
protected java.lang.String sendInfo(java.lang.String raw_msg)
Format an information message and send it to the log. This formats a raw information message and sends it to the info log. It returns the formatted message. The time stamp can be used to link the message in the log to any thrown exception or notation including the message. (Note: currently information messages do not trigger notations, but they may in the future.)- Specified by:
sendInfoin classAQBPLogger- Parameters:
raw_msg- the error message.- Returns:
- the formatted error message. If there is a failure sending the log message null should be returned.
-
sendTrace
protected java.lang.String sendTrace(java.lang.String raw_msg)
Format a Trace message and send it to the log. This formats a raw trace message and sends it to the info log. It returns the formatted message.- Specified by:
sendTracein classAQBPLogger- Parameters:
raw_msg- the error message.- Returns:
- the formatted error message. If there is a failure sending the log message null should be returned.
-
-