Full call stack:
1 tryLog(log("abc"))
2 tryLog.R#49: tryCatchLog(expr = expr, dump.errors.to.file = dump.errors.to.file, error = function(e) {
msg <- conditionMessage(e)
invisible(structure(msg, class = "try-error", condition = e))
}, silent.warnings = silent.warnings, silent.messages = silent.messages)
3 tryCatchLog.R#135: tryCatch(withCallingHandlers(expr, error = function(e) {
call.stack <- sys.calls()
{
.doTrace(browser())
log.message <- e$message
}
if (dump.errors.to.file == TRUE) {
dump.file.name <- format(Sys.time(), format = "dump_%Y%m%d_%H%M%S")
utils::dump.frames()
save.image(file = paste0(dump.file.name, ".rda"))
log.message <- paste0(log.message, "\nCall stack environments dumped into file: ", dump.file.name, ".rda")
}
log.entry <- build.log.entry(names(futile.logger::ERROR), log.message, call.stack, 1)
log.msg <- buildLogMessage(log.message, call.stack, 1)
append.to.last.tryCatchLog.result(log.entry)
futile.logger::flog.error(log.msg)
}, warning = function(w) {
call.stack <- sys.calls()
log.entry <- build.log.entry(names(futile.logger::WARN), w$message, call.stack, 1)
log.msg <- buildLogMessage(w$message, call.stack, 1)
append.to.last.tryCatchLog.result(log.entry)
futile.logger::flog.warn(log.msg)
if (silent.warnings) {
invokeRestart("muffleWarning")
}
else {
}
}, message = function(m) {
call.stack <- sys.calls()
log.entry <- build.log.entry(names(futile.logger::INFO), m$message, call.stack, 1)
log.msg <- buildLogMessage(m$message, call.stack, 1)
append.to.last.tryCatchLog.result(log.entry)
futile.logger::flog.info(log.msg)
if (silent.messages) {
invokeRestart("muffleMessage")
}
else {
}
}), ..., finally = finally)
4 tryCatchList(expr, classes, parentenv, handlers)
The unit test in the file
test_build_log_output.Rshows that the printed stack trace shows more characters per call thanmaxwidthis demanding, e. g. look into the expected values of the filebuild_log_output_test_data_2.txt. Call number 4 has more than 1000 characters in the output (which is way too much for logging it):The default value of
maxwidthisgetOption("width") - 5Lwhich is 129 minus 5 = 124.The problem is the missing assignment in the line
strtrim(value, maxwidth).