register_logger {teal.logger} | R Documentation |
Registers a logger instance in a given logging namespace.
Description
Usage
register_logger(namespace = NA_character_, layout = NULL, level = NULL)
Arguments
namespace |
( |
layout |
( |
level |
( |
Details
Creates a new logging namespace specified by the namespace
argument.
When the layout
and level
arguments are set to NULL
(default), the function
gets the values for them from system variables or R options.
When deciding what to use (either argument, an R option or system variable), the function
picks the first non NULL
value, checking in order:
Function argument.
System variable.
R option.
layout
and level
can be set as system environment variables, respectively:
-
teal.log_layout
asTEAL.LOG_LAYOUT
, -
teal.log_level
asTEAL.LOG_LEVEL
.
If neither the argument nor the environment variable is set the function uses the following R options:
-
options(teal.log_layout)
, which is passed tologger::layout_glue_generator()
, -
options(teal.log_level)
, which is passed tologger::log_threshold()
The logs are output to stdout
by default. Check logger
for more information
about layouts and how to use logger
.
Value
invisible(NULL)
Note
It's a thin wrapper around the logger
package.
See Also
The package vignettes for more help: browseVignettes("teal.logger")
.
Examples
options(teal.log_layout = "{msg}")
options(teal.log_level = "ERROR")
register_logger(namespace = "new_namespace")
logger::log_info("Hello from new_namespace", namespace = "new_namespace")