-2

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

tcl
  • 19
  • 3
  • It's easier to help you if you provide a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. It's not clear at the moment exactly what you are doing. – MrFlick Aug 28 '22 at 21:29

1 Answers1

2

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.

r2evans
  • 141,215
  • 6
  • 77
  • 149