loggit {loggit} | R Documentation |
Log entries to file
Description
This function executes immediately before the function definitions for the base handler functions (message, warning, and stop, and logs their timestamped output (a bit more verbosely) to a log file. The log file is an ndjson file, which is a portable, JSON-based format that is easily parsed by many line-processing systems.
Usage
loggit(log_lvl, log_msg, ..., echo = TRUE, custom_log_lvl = FALSE, sanitizer)
Arguments
log_lvl |
Level of log output. In actual practice, one of "DEBUG",
"INFO", "WARN", and "ERROR" are common, but any string may be supplied if
|
log_msg |
Main log message. Will be coerced to class |
... |
A named |
echo |
Should the log file entry be printed to the console as well?
Defaults to |
custom_log_lvl |
Allow log levels other than "DEBUG", "INFO", "WARN",
and "ERROR"? Defaults to |
sanitizer |
Sanitizer function to run over elements in log data. The
default sanitizer, if not specified, is |
Examples
loggit("INFO", "This is a message", but_maybe = "you want more fields?",
sure = "why not?", like = 2, or = 10, what = "ever")