Configure level-specific log files using the package logging API.
logger.setup(
traceLog = NULL,
debugLog = NULL,
infoLog = NULL,
warnLog = NULL,
errorLog = NULL,
fatalLog = NULL
)No return value. Called for side effects.
Logging is built on top of the logger package while retaining the historical MazamaCoreUtils logging interface.
Separate log files can be created for different log levels so that, for
example, an errorLog contains only ERROR and FATAL messages while a
debugLog contains DEBUG messages as well as all higher-severity messages.
Any log file argument left as NULL is disabled and no file will be created
for that level.
After initialization, logging statements can be generated with:
logger.trace(), logger.debug(), logger.info(),
logger.warn(), logger.error(), and logger.fatal().
Log messages are formatted with:
LEVEL [YYYY-MM-DD HH:MM:SS UTC] message
Console logging is enabled by default only for FATAL messages. Use
logger.setLevel() to display additional log messages in the console.
All functionality is implemented with the excellent logger package.
if (FALSE) { # \dontrun{
# Create three log files
logger.setup(
debugLog = "debug.log",
infoLog = "info.log",
errorLog = "error.log"
)
# Generate log messages
logger.trace("trace statement #%d", 1)
logger.debug("debug statement")
logger.info("info statement %s %s", "with", "arguments")
logger.warn("warn statement: %s", "about to try something risky")
result <- try(1 / "a", silent = TRUE)
logger.error("error message: %s", geterrmessage())
logger.fatal("fatal statement: %s", "THE END")
cat(readLines("debug.log"), sep = "\n")
cat(readLines("info.log"), sep = "\n")
cat(readLines("error.log"), sep = "\n")
} # }