Skip to contents

Prints a timestamped message to the console. Supports glue-style interpolation of variables from the calling environment. Optionally prints and returns a variable value, useful for debugging pipelines.

Usage

log_message(msg, variable = NULL)

log_msg(msg, variable = NULL)

Arguments

msg

Character. Message to log, supports glue syntax for variable interpolation.

variable

Optional. If provided, appends the value to the message and returns it invisibly.

Value

Invisibly returns NULL, or the variable if provided.

Examples

# Simple message
log_message("Starting the process...")
#> [2026-04-03 09:22:16] Starting the process...

# With variable interpolation
iso3 <- "KEN"
log_message("Processing {iso3}...")
#> [2026-04-03 09:22:16] Processing KEN...

# With variable return (useful in pipelines)
result <- log_message("Computed value", 42)
#> [2026-04-03 09:22:16] Computed value: 42