Filterable: Abstract Class for Filterables

FilterableR Documentation

Abstract Class for Filterables

Description

Superclass for classes that have a $filter() method such as Appenders and Loggers. See EventFilter for details.

NOTE: This is an abstract class. Abstract classes cannot be instantiated directly, but are exported for package developers that want to extend lgr - for example by creating their own Appenders or Layouts. Please refer to the see also section for actual implementations of this class.

Active bindings

filters

a list of all attached Filters.

Methods

Public methods


Method filter()

Determine whether the LogEvent x should be passed on to Appenders (TRUE) or not (FALSE). See also the active binding filters.

Usage
Filterable$filter(event)
Arguments
event

a LogEvent


Method add_filter()

Attach a filter

Usage
Filterable$add_filter(filter, name = NULL)
Arguments
filter
  • a function with the single argument event that returns TRUE or FALSE;

  • an EventFilter R6::R6 object; or

  • any R object with a $filter() method.

If a Filter returns a non-FALSE value, will be interpreted as TRUE (= no filtering takes place) and a warning will be thrown.

name

character scalar or NULL. An optional name which makes it easier to access (or remove) the filter


Method remove_filter()

Remove a filter

Usage
Filterable$remove_filter(pos)
Arguments
pos

character or integer scalar. The name or index of the Filter to be removed.


Method set_filters()

Set or replace (all) Filters of parent object. See EventFilter for how Filters work.

Usage
Filterable$set_filters(filters)
Arguments
filters

a list (named or unnamed) of EventFilters or predicate functions. See is_filter().

See Also

Other abstract classes: AppenderMemory, AppenderTable, Appender


s-fleck/memlog documentation built on March 6, 2023, 6:52 p.m.