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)TRUEorFALSE: Whether the buffer should be flushed when the Appender is garbage collected (f.e when you close R)flush_on_rotate, set_flush_on_rotateTRUEorFALSE: 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
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
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.
Arguments
xsingle Appender or a
listthereof. 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.
Arguments
appendera single Appender
namea
characterscalar. Optional but recommended.
Method remove_appender()
remove an appender