loggr
loggr copied to clipboard
Messages being truncated
I'm looking at using loggr in a scenario where I'm creating new processes using system2(command = "Rscript" , args = c('--vanilla','my_script.R'), stdout = stdout_file, stderr = stderr_file, wait = FALSE), where I use loggr inside the script my_script. However, when I compare the log file to the stderr file, the loggr file seems to have truncated the messages. For example, a stderr file might have the contents:
Warning messages:
1: There were 38 divergent transitions after warmup. Increasing adapt_delta above 0.8 may help. See
http://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup
2: Examine the pairs() plot to diagnose sampling problems
But the log file only has:
There were
Examine the pairs() plot to diagnose sampling problems
All I'm doing to activate loggr in my_script.R is:
library(loggr)
my_formatter <- function(event) event$message
log_file(log_file_name,.formatter = my_formatter,subscriptions=c('message', 'warning','stop'))
Any idea what I should be doing instead to avoid truncation of those messages?
dunno if it helps or not, but here's the code used by the package whose functions I'm using in my_script.R:
warning("There were ", n_d, " divergent transitions after warmup.",
" Increasing adapt_delta above ", ad, " may help. See\n",
"http://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup"
, call. = FALSE)
So it looks like loggr is only catching the first argument to warning()?
I think the problem is in notify_loggr where you only pass the first element of args to .makeMessage.
ok, think I fixed this, pull request here: https://github.com/smbache/loggr/pull/34