Class: BufferAppender

BufferAppender

BufferAppender extends SimpleLogAppender and implements an internal buffer store for log messages. The messages can be extracted from the buffer when needed. The buffer size can be limited or unlimited. If limited it is implemented as a FIFO queue.

new BufferAppender(level, category, size)

Constructor for BufferAppender.
Parameters:
Name Type Description
level String The threshold level at which the SimpleLogAppender is created. It should be one of "DEBUG", "INFO", "WARN", "ERROR" and "FATAL". If not or wrongly specified INFO is assumed.
category String The category this appender should listen to. If not specified the appender will get log for every available category. See SimpleLogAppender#setCategoryFilter.
size Number The maximum number of log messages stored in the internal buffer. If 0 or no value is passed, unlimited is assumed.

Extends

Method Summary

extractLog
Retrieve log messages from the buffer.
getLength
Gets the number of buffered lines
getLog
Retrieve log messages from the buffer.
log
Add a log message in the internal buffer.
reset
Operation method that resets the buffer making it empty.

Inherited Methods

Method Detail

extractLog(sepopt) → {String}

Retrieve log messages from the buffer. The extracted messages are then removed from the internal buffer.
Parameters:
Name Type Argument Description
sep String <optional>
separator string between the log messages in the result string. If null or not specified "\n" is used.
Returns:
a concatenated string of all the log messages that have been retrieved.
Type
String

getLength() → {Number}

Gets the number of buffered lines
Returns:
the number of buffered lines
Type
Number

getLog(maxRowsopt, sepopt, levelopt) → {String}

Retrieve log messages from the buffer. The extracted messages are NOT removed from the internal buffer.
Parameters:
Name Type Argument Description
maxRows Number <optional>
the number of log lines to be retrieved. If not specified all the available lines are retrieved.
sep String <optional>
separator string between the log messages in the result string. If not specified "\n" is used.
level String <optional>
the level of the log to be retrieved.
Returns:
a concatenated string of all the log messages that have been retrieved.
Type
String

log(category, level, mex, header)

Add a log message in the internal buffer.
Parameters:
Name Type Description
category String the logger category that produced the given message.
level String the logging level of the given message. It should be one of DEBUG INFO WARN ERROR FATAL.
mex String the message to be logged. It could be a String instance, an Error instance or any other object, provided that it has a toString method.
header String a header for the message
Overrides:

reset()

Operation method that resets the buffer making it empty.