logger: Generate logging utility

Description Usage Arguments Details Value Note References Examples

View source: R/logger.R

Description

A logger consists of a log level threshold, a log message formatter function, a log record layout formatting function and the appender function deciding on the destination of the log record. For more details, see the package README.md.

Usage

1
logger(threshold, formatter, layout, appender)

Arguments

threshold

omit log messages below this log_levels

formatter

function pre-processing the message of the log record when it's not wrapped in a skip_formatter call

layout

function rendering the layout of the actual log record

appender

function writing the log record

Details

By default, a general logger definition is created when loading the logger package, that uses

  1. INFO as the log level threshold

  2. layout_simple as the layout function showing the log level, timestamp and log message

  3. formatter_glue (or formatter_sprintf if glue is not installed) as the default formatter function transforming the R objects to be logged to a character vector

  4. appender_console as the default log record destination

Value

function taking level and msg arguments

Note

It's quite unlikely that you need to call this function directly, but instead set the logger parameters and functions at log_threshold, log_formatter, log_layout and log_appender and then call log_levels and its derivatives, such as log_info directly.

References

For more details, see the Anatomy of a Log Request vignette at https://daroczig.github.io/logger/articles/anatomy.html.

Examples

1
2
3
4
5
6
7
## Not run: 
do.call(logger, logger:::namespaces$global[[1]])(INFO, 42)
do.call(logger, logger:::namespaces$global[[1]])(INFO, '{pi}')
x <- 42
do.call(logger, logger:::namespaces$global[[1]])(INFO, '{x}^2 = {x^2}')

## End(Not run)

logger documentation built on July 6, 2021, 5:07 p.m.