R/logging.R
flog.Rd
Like other logging approaches, each message created with this function is
assigned a level
(priority). If the current logging level, which is
returned from a call to flog_level
(ostensibly determenied by the value
of the "facile.log.level(.*?)"
option) is less than or equal to level of
this message, then the message will be generated and sent to file
.
You can include a namespace
for the message to provide a namespace-specific
level/priority hierarchy.
flog( ..., level = "info", ns = NULL, session = NULL, file = stderr(), sep = "", fill = FALSE, labels = NULL, append = FALSE, newline = !is.null(file) )
... | the string elements to pass into |
---|---|
level | the "firing level" of this message. Defaults to "info" |
ns | (namespace) if included, then the message checks the namespace-specific logging priority |
session, file, sep, fill, labels, append | sent to |
newline | If |
invisibly returns the text generated in the logging message.
Conveninece wrapper functions are provided for each logging level, ie.
call fwarn("message")
instead of flog("message", level = "warn"). Also, each facile* package provides its own
flog()function which sets the namespace
ns` parameter to default to a package-specific namespace so you
can control logging at the different package level.
Logging levels are
.flog_levels <- c("all" = 0, "trace" = 1, "debug" = 2, "info" = 3, "warn" = 4, "error" = 5, "fatal" = 6)
Glue lets you put cayon functions in {}
to stylize output. For instance,
you can make "bold and red" the color red and also bold, like so:
flog("This is {red}{bold}bold and red{reset}, right?")
Nice! It might be more convenient if we could make it a bit more terse, as shown below, but that might happen at another time.
flog("This is rb`bold and red`, right?")
Colors:
b: blue
c: cyan
g: green
k: black
m: magenta
r: red
y: yellow
Styles:
i: italic
s: strong (bold)
S: striketthrough
u: underline