An Appender that Buffers LogEvents in-memory and and redirects them to other Appenders once certain conditions are met.
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
or FALSE
: 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
or FALSE
: 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.
lgr::Filterable
-> lgr::Appender
-> lgr::AppenderMemory
-> AppenderBuffer
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()
new()
The Layout for this Appender is used only to format console output of
its $show()
method.
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
)
flush()
Sends the buffer's contents to all attached Appenders and then clears the Buffer
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.
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 (see vignette("lgr", package = "lgr")
for more info
about Logger inheritance).
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.
appender
a single Appender
name
a character
scalar. Optional but recommended.
remove_appender()
remove an appender
format()