logf | R Documentation |
Prints a formatted string with optional prefix and end string. The default prefix is a grey timestamp and the default end is a newline character, which is useful for logging messages. All defaults can be set globally using options()
. For details see 'Examples'.
logf(
fmt,
...,
file = .Options$toscutil.logf.file %||% "",
append = .Options$toscutil.logf.append %||% FALSE,
prefix = .Options$toscutil.logf.prefix %||% function() now_ms(usetz = FALSE, color =
fg$GREY),
sep1 = .Options$toscutil.logf.sep1 %||% " ",
sep2 = .Options$toscutil.logf.sep2 %||% "",
end = .Options$toscutil.logf.end %||% "\n"
)
... |
Arguments to be passed to sprintf for string formatting. |
file |
A |
append |
Logical. If |
prefix |
A function returning a string to be used as the prefix. |
sep1 |
A string to be used as the separator between the prefix and the formatted string. |
sep2 |
A string to be used as the separator between the formatted string and the end. |
end |
A string to be used as the end of the message. |
No return value. This function is called for its side effect of printing a message.
logf("Hello, %s!", "world")
logf("Goodbye", prefix = function() "", sep1 = "", end = "!\n")
local({
opts <- options(toscutil.logf.prefix = function() "LOG:", toscutil.logf.end = "\n")
on.exit(options(opts))
logf("Hello, %s!", "world")
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.