Last chance! 50% off unlimited learning
Sale ends in
with_log_level
temporarily overrides the log level of all LogEvents
created by target Logger.
with_log_level(level, code, logger = lgr::lgr)with_log_value(values, code, logger = lgr::lgr)
integer
or character
scalar: the desired log level
Any R code
a Logger or the name of one (see get_logger()
). Defaults
to the root logger (lgr::lgr
).
a named list
of values to be injected into the logging calls
whatever code
would return
These functions abuses lgr's filter mechanic to modify LogEvents in-place before they passed on the Appenders. Use with care as they can produce hard to reason about code.
# NOT RUN {
with_log_level("warn", {
lgr$info("More important than it seems")
lgr$fatal("Really not so bad")
})
with_log_value(
list(msg = "overriden msg"), {
lgr$info("bar")
lgr$fatal("FOO")
})
# }
Run the code above in your browser using DataLab