Learn R Programming

lgr (version 0.3.4)

Appender: Appenders

Description

Appenders are assigned to Loggers and manage the output of the LogEvents to a destination (such as the console or a text file). An Appender has a single Layout that tells it how to format the LogEvent. For details please refer to the documentations of the specific Appenders.

The Appender class itself is not designed for direct usage, but it is the basis on which all other Appenders are built. Please see the see also section towards the end of this document a list of available Appenders.

Arguments

Usage

x <- Appender$new(layout = Layout$new(), threshold = NA_integer_)

x$add_filter(filter, name = NULL) x$append(event) x$filter(event) x$format(color = FALSE, ...) x$remove_filter(pos) x$set_filters(filters) x$set_layout(layout) x$set_threshold(level)

x$destination x$filters x$layout x$threshold

Creating a New Appender

New Appenders are instantiated with <AppenderSubclass>$new(). For the arguments to new() please refer to the section Fields. You can also modify those fields after the Appender has been created with setters in the form of appender$set_<fieldname>(value)

Fields

threshold, set_threshold(level)

character or integer scalar. The minimum log level that triggers this logger. See log_levels

layout, set_layout(layout)

a Layout that will be used for formatting the LogEvents passed to this Appender

destination

The output destination of the Appender in human-readable form (mainly for print output)

filters, set_filters(filters)

a list that may contain functions or any R object with a filter() method. These functions must have exactly one argument: event which will get passed the LogEvent when the Filterable's filter() method is invoked. If all of these functions evaluate to TRUE the LogEvent is passed on. Since LogEvents have reference semantics, filters can also be abused to modify them before they are passed on. Look at the source code of with_log_level() or with_log_value() for examples.

Methods

append(event)

Tell the Appender to process a LogEvent event. This method is usually not called by the user, but invoked by a Logger

filter(event)

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

add_filter(filter, name = NULL), remove_filter(pos)

Add or remove a filter. When adding a filter an optional name can be specified. remove_filter() can remove by position or name (if one was specified)

See Also

Other Appenders: AppenderBuffer, AppenderConsole, AppenderDbi, AppenderFileRotating, AppenderFile, AppenderGmail, AppenderJson, AppenderPushbullet, AppenderRjdbc, AppenderSendmail, AppenderSyslog, AppenderTable