logger | R Documentation |
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
.
logger(threshold, formatter, layout, appender)
threshold |
omit log messages below this |
formatter |
function pre-processing the message of the log
record when it's not wrapped in a |
layout |
function rendering the layout of the actual log record |
appender |
function writing the log record |
By default, a general logger definition is created when loading the logger
package, that uses
INFO()
(or as per the LOGGER_LOG_LEVEL
environment variable override) as the log level threshold
layout_simple()
as the layout function showing the log level, timestamp and log message
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
appender_console()
as the default log record destination
A function taking the log level
to compare with the set
threshold, all the ...
arguments passed to the formatter
function, besides the standard namespace
, .logcall
,
.topcall
and .topenv
arguments (see log_level()
for more
details). The function invisibly returns a list including the
original level
, namespace
, all ...
transformed to a list as
params
, the log message
(after calling the formatter
function) and the log record
(after calling the layout
function), and a list of handlers
with the formatter
,
layout
and appender
functions.
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.
For more details, see the Anatomy of a Log Request vignette at https://daroczig.github.io/logger/articles/anatomy.html.
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.