AppenderBuffer {lgr} | R Documentation |
Log to a memory buffer
Description
An Appender that Buffers LogEvents in-memory and and redirects them to other Appenders once certain conditions are met.
Fields
appenders
,set_appenders()
Like for a Logger. Buffered events will be passed on to these Appenders once a flush is triggered
flush_on_exit, set_flush_on_exit(x)
TRUE
orFALSE
: Whether the buffer should be flushed when the Appender is garbage collected (f.e when you close R)flush_on_rotate, set_flush_on_rotate
TRUE
orFALSE
: Whether the buffer should be flushed when the Buffer is full (f.e when you close R). Setting this to off can have slightly negative performance impacts.
Super classes
lgr::Filterable
-> lgr::Appender
-> lgr::AppenderMemory
-> AppenderBuffer
Methods
Public methods
Inherited methods
lgr::Filterable$add_filter()
lgr::Filterable$filter()
lgr::Filterable$remove_filter()
lgr::Filterable$set_filters()
lgr::Appender$set_layout()
lgr::Appender$set_threshold()
lgr::AppenderMemory$append()
lgr::AppenderMemory$set_buffer_size()
lgr::AppenderMemory$set_flush_on_exit()
lgr::AppenderMemory$set_flush_on_rotate()
lgr::AppenderMemory$set_flush_threshold()
lgr::AppenderMemory$set_should_flush()
lgr::AppenderMemory$show()
Method new()
The Layout for this Appender is used only to format console output of
its $show()
method.
Usage
AppenderBuffer$new( threshold = NA_integer_, layout = LayoutFormat$new(fmt = "%L [%t] %m", timestamp_fmt = "%H:%M:%S", colors = getOption("lgr.colors")), appenders = NULL, buffer_size = 1000, flush_threshold = NULL, flush_on_exit = TRUE, flush_on_rotate = TRUE, should_flush = NULL, filters = NULL )
Method flush()
Sends the buffer's contents to all attached Appenders and then clears the Buffer
Usage
AppenderBuffer$flush()
Method clear()
Clears the buffer, discarding all buffered Events
Usage
AppenderBuffer$clear()
Method set_appenders()
Exactly like A Logger, an AppenderBuffer can have an arbitrary amount of Appenders attached. When the buffer is flushed, the buffered events are dispatched to these Appenders.
Usage
AppenderBuffer$set_appenders(x)
Arguments
x
single Appender or a
list
thereof. Appenders control the output of a Logger. Be aware that a Logger also inherits the Appenders of its ancestors (seevignette("lgr", package = "lgr")
for more info about Logger inheritance).
Method add_appender()
Add an Appender to the AppenderBuffer
Add or remove an Appender. Supplying a name
is optional but
recommended. After adding an Appender with
appender$add_appender(AppenderConsole$new(), name = "console")
you can
refer to it via appender$appenders$console
. remove_appender()
can
remove an Appender by position or name.
Usage
AppenderBuffer$add_appender(appender, name = NULL)
Arguments
appender
a single Appender
name
a
character
scalar. Optional but recommended.
Method remove_appender()
remove an appender
Usage
AppenderBuffer$remove_appender(pos)
Arguments
pos
integer
index orcharacter
name of the Appender(s) to remove
Method format()
Usage
AppenderBuffer$format(...)
See Also
Other Appenders:
AppenderConsole
,
AppenderFileRotatingDate
,
AppenderFileRotatingTime
,
AppenderFileRotating
,
AppenderFile
,
AppenderTable
,
Appender