Home > Mobile >  why is r logger returning code not results (counts)
why is r logger returning code not results (counts)

Time:08-29

Using r logger for returning a log but it is returning the code. In the past it worked fine.

example of what is returned:

INFO [2022-08-27 07:13:22] {package_log}::{func_string} returned {nrow(result)} rows

CodePudding user response:

My guess is that somewhere you changed the default formatter for logging.

Long story short, reproducible and a fix:

library(logger)
log_info("hello {nrow(mtcars)}")
# INFO [2022-08-28 17:32:00] hello 32
log_formatter(formatter_sprintf)
log_info("hello {nrow(mtcars)}")
# INFO [2022-08-28 17:33:56] hello {nrow(mtcars)}
log_formatter(formatter_glue)
log_info("hello {nrow(mtcars)}")
# INFO [2022-08-28 17:34:00] hello 32

You can read more about formatters in Customizing the Format and the Destination of a Log Record, one of the package vignettes.

  • Related