Integrate the message printing function with the cli package, and the message function. The message could be suppressed by suppressMessages.

log_message(
  ...,
  verbose = TRUE,
  message_type = c("info", "success", "warning", "error"),
  cli_model = TRUE
)

Arguments

...

Text to print.

verbose

Logical value, default is TRUE. Whether to print the message.

message_type

Type of message, default is info. Could be choose one of info, success, warning, and error.

cli_model

Logical value, default is TRUE. Whether to use the cli package to print the message.

Examples

log_message("Hello, ", "world!")
#>  Hello, world!
log_message("Hello, ", "world!", message_type = "success")
#>  Hello, world!
log_message("Hello, world!", message_type = "warning")
#> ! Hello, world!
suppressMessages(log_message("Hello, ", "world!"))
log_message("Hello, world!", verbose = FALSE)