log_message | R Documentation |
Integrate the message printing function with the cli
package,
and the base::message function.
The message could be suppressed by base::suppressMessages.
log_message(
...,
verbose = TRUE,
message_type = c("info", "success", "warning", "error"),
cli_model = TRUE,
timestamp = TRUE,
timestamp_format = "%Y-%m-%d %H:%M:%S",
level = 1,
symbol = " ",
format = FALSE,
text_color = NULL,
back_color = NULL,
multiline_indent = TRUE
)
... |
Text to print. |
verbose |
Logical value, default is |
message_type |
Type of message, default is |
cli_model |
Logical value, default is |
timestamp |
Logical value, default is |
timestamp_format |
Character value, default is |
level |
Integer value, default is |
symbol |
Character value, default is |
format |
Logical value, default is |
text_color |
Character value, default is |
back_color |
Character value, default is |
multiline_indent |
Logical value, default is |
Formated message
printed to the console.
https://cli.r-lib.org/articles/index.html
# basic usage
log_message("Hello, ", "world!")
log_message("hello, world!")
log_message("Hello, world!", timestamp = FALSE)
log_message("Hello, ", "world!", message_type = "success")
log_message("Hello, world!", message_type = "warning")
log_message("Hello, ", "world!", cli_model = FALSE)
# suppress messages
suppressMessages(log_message("Hello, world!"))
log_message("Hello, world!", verbose = FALSE)
# cli formatting
log_message("hello, {.arg world}!")
message("hello, {.arg world}!")
log_message("hello, {.code world}!")
message("hello, {.code world}!")
log_message("{.emph R}")
log_message("Hello, {.file world}!")
log_message("press {.kbd ENTER}")
log_message("address: {.email example@example.com}")
log_message("URL: {.url https://example.com}")
log_message("Some {.field field}")
log_message("Hello, {.pkg world}!")
log_message("Hello, {.val world}!")
# set indentation
log_message("Hello, world!", level = 2)
log_message("Hello, world!", symbol = "->")
log_message("Hello, %s", "world!", format = TRUE)
log_message("Processing %d items", 42, format = TRUE)
# multiline message
log_message("Line 1\nLine 2\nLine 3", multiline_indent = TRUE)
log_message(
"Multi-line\ncolored\nmessage",
text_color = "blue",
multiline_indent = FALSE
)
log_message(
"Multi-line\ncolored\nmessage",
text_color = "blue",
multiline_indent = FALSE,
timestamp = FALSE
)
# color formatting
log_message(
"This is a red message",
text_color = "red"
)
log_message(
"This is a message with background",
back_color = "cyan"
)
log_message(
"This is a message with both text and background",
text_color = "red",
back_color = "cyan"
)
# color formatting also works with `cli_model = FALSE`
log_message(
"This is a red message",
text_color = "red",
cli_model = FALSE
)
log_message(
"This is a message with background",
back_color = "cyan",
cli_model = FALSE
)
log_message(
"This is a message with both text and background",
text_color = "red",
back_color = "cyan",
cli_model = FALSE
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.