An Appender that writes to the syslog on supported POSIX platforms. Requires the rsyslog package.
x <- AppenderSyslog$new(identifier = NULL, threshold = NA_integer_, layout = LayoutFormat$new("%m"), filters = NULL, syslog_levels = c(CRITICAL = "fatal", ERR = "error", WARNING = "warn", INFO = "info", DEBUG = "debug", DEBUG = "trace"))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_identifier(x) x$set_layout(layout) x$set_syslog_levels(x) x$set_threshold(level)
x$destination x$filters x$identifier x$layout x$syslog_levels x$threshold
identifier
character
scalar. A string identifying the process;
if NULL
defaults to the logger name
syslog_levels
a named character
vector mapping whose names are log levels as
understood by rsyslog::syslog()
and whose values are
lgr log levels (either character
or numeric
)
a function
that takes a vector of lgr log levels as input and returns a
character
vector of log levels for rsyslog::syslog()
.
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.
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)
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)
Other Appenders: AppenderBuffer
,
AppenderConsole
, AppenderDbi
,
AppenderFileRotating
,
AppenderFile
, AppenderGmail
,
AppenderJson
,
AppenderPushbullet
,
AppenderRjdbc
,
AppenderSendmail
,
AppenderTable
, Appender
# NOT RUN {
if (requireNamespace("rsyslog", quietly = TRUE)) {
lg <- get_logger("rsyslog/test")
lg$add_appender(AppenderSyslog$new(), "syslog")
lg$info("A test message")
if (Sys.info()[["sysname"]] == "Linux"){
system("journalctl -t 'rsyslog/test'")
}
invisible(lg$config(NULL)) # cleanup
}
# }
Run the code above in your browser using DataLab