-
Notifications
You must be signed in to change notification settings - Fork 2
Description
In the current loggit.R, echoing of log message is handled by write_ndjson()
write_ndjson(log_df, echo = echo)
Line 83 in 5399852
| write_ndjson(log_df, echo = echo) |
which in turn calls cat() if echo = T.
if (echo) cat(logdata, sep = "\n")
Line 102 in 5399852
| if (echo) cat(logdata, sep = "\n") |
Previously, in version 1.1.1 (https://cran.r-project.org/src/contrib/Archive/loggit/loggit_1.1.1.tar.gz), if echo = T, the base message function is called in loggit.R.
if (echo) base::message(paste(c(log_lvl, log_msg), collapse = ": "))
Switching to from message() to cat() causes loggit output to console to be suppressed during R markdown rendering as knitr::knit_hooks has options to handle message() output but nothing to handle cat() output (https://bookdown.org/yihui/rmarkdown-cookbook/output-hooks.html).
Here is an example code snippet (I replaced the markdown backticks with a single quote because I can't figure out a way not to confused the code blocking):
'''{r setup, include=FALSE}
library(loggit)
'''
'''{r test message, echo=F,message=F, warning=F}
loggit("INFO", "loggit message", echo = T)
message('base message\n')
'''
Only "base message" will be printed to console during rendering.
I suggest switching back from cat() to message() when echo = T.