lgr provides convenience functions managing the root Logger. These are
designed chiefly for interactive use and are less verbose than their
R6 method counterparts.
threshold()
sets or retrieves the threshold for an Appender or Logger
(the minimum level of log messages it processes). It's target
defaults to
the root logger. (equivalent to lgr::lgr$threshold
and
lgr::lgr$set_threshold
)
console_threshold()
is a shortcut to set the threshold of the root
loggers AppenderConsole, which is usually the only Appender that manages
console output for a given R session. (equivalent to
lgr::lgr$appenders$console$threshold
and
lgr::lgr$appenders$console$set_threshold
)
add_appender()
and remove_appender()
add Appenders to Loggers and other
Appenders. (equivalent to lgr::lgr$add_appender
and
lgr::lgr$remove_appender
)
show_log()
displays the last n
log entries of an Appender (or a Logger
with such an Appender attached) with a $show()
method. Most, but not all
Appenders support this function (try AppenderFile or AppenderBuffer).
show_data()
and show_dt()
work similar to show_log()
, except that
they return the log as data.frame
or data.table
respectively. Only
Appenders that log to formats that can easily be converted to data.frames
are supported (try AppenderJson or AppenderBuffer).
The easiest way to try out this features is by adding an AppenderBuffer
to the root logger with basic_config(memory = TRUE)
.