Skip to contents

The logging function that pip_run() uses by default. It writes one line per message to the console in the form <level> [<UTC time stamp>]: <msg>, for example info [2026-01-01 12:34:56.789 UTC]: Step 1/2 load.

Usage

pipeflow_lgr(level, msg)

Arguments

level

The log level, one of "info", "warn" or "error".

msg

The message, a single string.

Value

NULL, invisibly.

Details

It is exported so that custom loggers can build on it, for example to add a prefix, or to drop some levels and pass the rest on to the default logger. A logger is any function with the arguments level and msg. pip_run() calls it as lgr(level = level, msg = msg).

See also

pip_run() for how loggers are used and how to switch logging off with lgr = NULL.

Examples

pipeflow_lgr("info", "Hello")
#> info [2026-10-13 15:27:10.326 UTC]: Hello

p <- pip_new("demo") |>
    pip_add("load", \(n = 3) seq_len(n)) |>
    pip_add("double", \(x = ~load) x * 2)

# Add a prefix to every message
prefixed <- function(level, msg) {
    pipeflow_lgr(level, paste("[demo]", msg))
}
pip_run(p, lgr = prefixed)
#> info [2026-10-13 15:27:10.330 UTC]: [demo] Starting run of pipeflow 'demo'
#> info [2026-10-13 15:27:10.330 UTC]: [demo] Step 1/2 load
#> info [2026-10-13 15:27:10.331 UTC]: [demo] Step 2/2 double
#> info [2026-10-13 15:27:10.332 UTC]: [demo] Finished run of pipeflow 'demo'

# Drop the "info" messages and pass the rest on
quiet <- function(level, msg) {
    if (level != "info") {
        pipeflow_lgr(level, msg)
    }
}
pip_run(p, lgr = quiet, force = TRUE)