ryapric / loggit

Modern Logging for the R Ecosystem
Other
37 stars 2 forks source link

Multiline messages will be destroyed #18

Open sigbertklinke opened 2 years ago

sigbertklinke commented 2 years ago
msg <- paste0("Package: smvgraph %s", utils::packageVersion("smvgraph"), "\n(C) 2022- Sigbert Klinke, HU Berlin")
loggit("DEBUG", msg, echo=FALSE)

leads in the loggit file to

{"timestamp": "2022-03-19T18:51:36+0100", "log_lvl": "DEBUG", "log_msg": "Package: smvgraph %s0.2.0__LF__(C) 2022- Sigbert Klinke__COMMA__ HU Berlin"}

But reading the log into R produces

read_logs()
                 timestamp log_lvl log_msg
1 2022-03-19T18:51:36+0100   DEBUG Package
ryapric commented 2 years ago

Thanks! Can you please post your sessionInfo() output, including the version of loggit being used?

If this is reproducible, I'll get to work on a fix -- but that fix might end up being a new major version (3.x) depending on the changes.

I would, however, bring your attention to the release notes for v2.0.0, and ask if you're correctly seeing this warning when your message has a newline?

ryapric commented 2 years ago

Oh, it's not the multiline, it's your colon after Package:

msg <- paste0("Package smvgraph %s", utils::packageVersion("smvgraph"), "\n(C) 2022- Sigbert Klinke, HU Berlin")
loggit("DEBUG", msg, echo=FALSE)
read_logs()
                 timestamp log_lvl log_msg
1 2022-03-19T18:51:36+0100   DEBUG Package smvgraph %s0.2.0\n(C) 2022- Sigbert Klinke, HU Berlin

Please confirm that you see the same. If so, that's an easy fix to the default sanitizer and preparser.