smbache / loggr

Easy and flexible logging for R
Other
79 stars 6 forks source link

Avoid logging handled exceptions #31

Open aschmu opened 7 years ago

aschmu commented 7 years ago

Hi I can't figure out how to do this, maybe this needs a pull request. Basically what I mean to do is to source the following R script:

log_file("testloggr.log", overwrite = TRUE, INFO)
log_info("I want to log this to keep a trace")
e <- sin(pi/6)
#But I don't wish to see any traceback in the logfile for the following
try(log("e"))

#I certainly don't want to see any output from this
fun <- function() {
 a <- tryCatch(na.fail(NA),
           error = function(e) 1)
 a
}
fun()

The last function call writes a message to the logfile which I do not want. Also for some weird reason if I change the INFO log level to DEBUG, there's no more log_info output. I find this strange since I assume DEBUG is a more verbose mode which should include INFO or maybe I'm missing something.

The use case is am running a bunch of R scripts from the command line and I wan't to log them properly for production mainly.