Create a json-emitting logger, using the 'lgr' package.
porcelain_logger(log_level = "info", name = NULL, path = NULL)
The level of detail to log to. See
lgr::get_log_levels()
for possible values; this could be a
string ("off", "info", "all", etc) or an integer level.
The name of the logger. By default we use one derived from the package name, though this may not always be accurate.
Optionally, the path to log into. If not given then we log to the console.
A "Logger" object (see lgr::Logger)
logger <- porcelain::porcelain_logger(name = "example")
logger$log("info", "hello")
#> {"level":400,"timestamp":"2024-02-29 13:56:30","logger":"example","caller":"eval","msg":"hello","package_id":null}
logger$log("trace", "silent")