setup {spdl}R Documentation

Convenience Wrappers for 'RcppSpdlog' Logging From 'spdlog'

Description

Several short wrappers for functions from 'RcppSpdlog' package are provided as a convenience. Given the potential for clashing names of common and popular functions names we do not recommend the import the whole package but rather do importFrom(RcppSpdlog, set_pattern) (or maybe importFrom(RcppSpdlog, set_pattern)). After that, functionality can be accessed via a convenient shorter form such as for example spdl::info() to log at the ‘info’ level. Format strings suitable for the C++ library ‘fmtlib::fmt’ and its fmt::format() (which as of C++20 becomes ‘std::fmt’) are supported so the {} is the placeholder for simple (scalar) arguments (for which the default R formatter is called before passing on a character representation).

Usage

setup(name = "default", level = "warn")

init(level = "warn")

log(level = "warn")

filesetup(s, name = "default", level = "warn")

drop(s)

set_pattern(s)

set_level(s)

trace(s, ...)

debug(s, ...)

info(s, ...)

warn(s, ...)

error(s, ...)

critical(s, ...)

fmt(s, ...)

cat(...)

stopwatch()

elapsed(w)

Arguments

name

Character value for the name of the logger instance

level

Character value for the logging level

s

Character value for filename, pattern, level, or logging message

...

Supplementary arguments for the logging string

w

Stopwatch object

Value

Nothing is returned from these functions as they are invoked for their side-effects.

Examples

spdl::setup("exampleDemo", "warn")
# and  spdl::init("warn")  and  spdl::log("warn")  are shortcuts
spdl::info("Not seen as level 'info' below 'warn'")
spdl::warn("This warning message is seen")
spdl::set_level("info")
spdl::info("Now this informational message is seen too")
spdl::info("Calls use fmtlib::fmt {} as we can see {}", "under the hood", 42L)

[Package spdl version 0.0.5 Index]