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,
timestamp = TRUE,
level = 1,
level_symbol = " "
)
Text to print.
Logical value, default is TRUE
.
Whether to print the message.
Type of message, default is info
.
Could be choose one of info
, success
, warning
, and error
.
Logical value, default is TRUE
.
Whether to use the cli
package to print the message.
Logical value, default is TRUE
.
Whether to show the current time in the message.
Integer value, default is 1
.
The level of the message, which affects the indentation.
Level 1 has no indentation, higher levels add more indentation.
Character value, default is " "
(two spaces).
The symbol used for indentation at each level.
log_message("Hello, ", "world!")
#> ℹ [2025-04-22 07:40:11] Hello, world!
log_message("Hello, world!", timestamp = FALSE)
#> ℹ Hello, world!
log_message("Hello, ", "world!", message_type = "success")
#> ✔ [2025-04-22 07:40:11] Hello, world!
log_message("Hello, world!", message_type = "warning")
#> ! [2025-04-22 07:40:11] Hello, world!
suppressMessages(log_message("Hello, ", "world!"))
log_message("Hello, world!", verbose = FALSE)
log_message("Hello, world!", level = 2)
#> ℹ [2025-04-22 07:40:11] Hello, world!
log_message("Hello, world!", level = 3, level_symbol = "->")
#> ℹ ->->[2025-04-22 07:40:11] Hello, world!