Skip to content

This is the main interface for configuring logging behaviour. We adopt the well-known log4j etymology: Appenders are destinations (e.g. the console or a file) where logs are written, and the Layout is the format of these logs.

Usage

logger(threshold = "INFO", appenders = console_appender())

Arguments

threshold

The logging threshold, one of "DEBUG", "INFO", "WARN", "ERROR", or "FATAL". Logs with a lower severity than the threshold will be discarded.

appenders

The logging appenders; both single appenders and a list() of them are supported. See Appenders.

Value

An object of class "logger".

See also

Appenders and Layouts for information on controlling the behaviour of the logger object.

Examples

# By default, logs are written to the console at the "INFO" threshold.
logger <- logger()

log_info(logger, "Located nearest gas station.")
#> INFO  [2024-10-18 17:06:49] Located nearest gas station.
log_warn(logger, "Ez-Gas sensor network is not available.")
#> WARN  [2024-10-18 17:06:49] Ez-Gas sensor network is not available.
log_debug(logger, "Debug messages are suppressed by default.")