Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

FilterInject

Inject values into all events processed by a Logger/Appender


Description

Inject arbitrary values into all LogEvents processed by a Logger/Appender. It is recommended to use filters that modify LogEvents only with Loggers, but they will also work with Appenders.

Super class

lgr::EventFilter -> FilterInject

Public fields

values

a named list of values to be injected into each LogEvent processed by this filter

Methods

Public methods

Inherited methods

Method new()

Initialize a new FilterInject

Usage
FilterInject$new(..., .list = list())
Arguments
..., .list

any number of named R objects that will be injected as custom fields into all LogEvents processed by the Appender/Logger that this filter is attached to. See also with_log_value().


Method clone()

The objects of this class are cloneable with this method.

Usage
FilterInject$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples

lg <- get_logger("test")

analyse <- function(){
  lg$add_filter(FilterInject$new(type = "analysis"), "inject")
  on.exit(lg$remove_filter("inject"))
  lg$error("an error with forced custom 'type'-field")
}

analyse()
lg$error("an normal error")
lg$config(NULL)  # reset config

lgr

A Fully Featured Logging Framework

v0.4.2
MIT + file LICENSE
Authors
Stefan Fleck [aut, cre] (<https://orcid.org/0000-0003-3344-9851>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.