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 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.

Super classes

lgr::Filterable -> lgr::Appender -> lgr::AppenderMemory -> AppenderBuffer

Methods

Public methods

Inherited methods

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 (see vignette("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 or character name of the Appender(s) to remove


Method format()

Usage
AppenderBuffer$format(...)

See Also

LayoutFormat

Other Appenders: AppenderConsole, AppenderFileRotatingDate, AppenderFileRotatingTime, AppenderFileRotating, AppenderFile, AppenderTable, Appender


[Package lgr version 0.4.4 Index]