Keep track of messages printed by modules or functions
Usage
logger(
...,
level = c("info", "success", "warning", "error", "fatal", "debug", "trace"),
calc_delta = "auto",
.envir = parent.frame(),
.sep = "",
use_glue = FALSE,
reset_timer = FALSE
)
set_logger_path(root_path, max_bytes, max_files)
logger_threshold(
level = c("info", "success", "warning", "error", "fatal", "debug", "trace"),
module_id,
type = c("console", "file", "both")
)
logger_error_condition(cond, level = "error")
Arguments
- ..., .envir, .sep
passed to
glue
, ifuse_glue
is true- level
the level of message, choices are
'info'
(default),'success'
,'warning'
,'error'
,'fatal'
,'debug'
,'trace'
- calc_delta
whether to calculate time difference between current message and previous message; default is
'auto'
, which prints time difference whenlevel
is'debug'
. This behavior can be changed by alteringcalc_delta
by a logicalTRUE
to enable orFALSE
to disable.- use_glue
whether to use
glue
to combine...
; default is false- reset_timer
whether to reset timer used by
calc_delta
- root_path
root directory if you want log messages to be saved to hard disks; if
root_path
isNULL
,""
, ornullfile
, then logger path will be unset.- max_bytes
maximum file size for each logger partitions
- max_files
maximum number of partition files to hold the log; old files will be deleted.
- module_id
'RAVE' module identification string, or name-space; default is
'base'
- type
which type of logging should be set; default is
'console'
, if file log is enabled throughset_logger_path
,type
could be'file'
or'both'
. Default log level is'info'
on console and'debug'
on file.- cond
condition to log
Examples
logger("This is a message")
a <- 1
logger("A message with glue: a={a}")
logger("A message without glue: a={a}", use_glue = FALSE)
logger("Message A", calc_delta = TRUE, reset_timer = TRUE)
logger("Seconds before logging another message", calc_delta = TRUE)
# by default, debug and trace messages won't be displayed
logger('debug message', level = 'debug')
# adjust logger level, make sure `module_id` is a valid RAVE module ID
logger_threshold('debug', module_id = NULL)
# Debug message will display
logger('debug message', level = 'debug')
# Trace message will not display as it's lower than debug level
logger('trace message', level = 'trace')