Several R-level functions can access the spdlog logging
facilties. As spdlog is a C++-level logging library, these
are R function permit concurrent logging from both R and C++.
log_setup(name = "default", level = "warn")
log_init(level = "warn")
log_filesetup(filename, name = "default", level = "warn")
log_drop(name)
log_set_pattern(s)
log_set_level(s)
log_trace(s)
log_debug(s)
log_info(s)
log_warn(s)
log_error(s)
log_critical(s)
name
|
A character variable with the logging instance name, default value is ‘default’. |
level
|
A character variable with the default logging level, default value is ‘warn’. |
filename
|
A character variable with the logging filename if a file-based logger is instantiated. |
s
|
A character variable with the logging pattern, level or message. |
Several functions are provided:
log_setup
log_filesetup
log_drop
log_set_pattern
log_set_level
log_trace
log_debug
log_info
log_warn
log_error
log_critical
Supported logging levels are, in order of increasing threshold values, ‘trace’, ‘debug’, ‘info’, ‘warn’, ‘error’, and ‘critical’. A message issued below the current threshold is not displayed whereas a message at or above the current threshold is displayed. The default level is ‘warn’.
Nothing is returned from these functions as they are invoked for their side-effects.
The logging pattern format is described in at the repo in the page https://github.com/gabime/spdlog/wiki/3.-Custom-formatting.
library("RcppSpdlog")
log_setup("demo") # at default level 'warn'
log_info("this message is NOT seen")
log_set_level("debug")
log_info("this message is seen")
[2025-10-11 14:16:03.482] [demo] [Process: 358] [info] this message is seen
log_warn("as is this message")
[2025-10-11 14:16:03.482] [demo] [Process: 358] [warning] as is this message