logger icon indicating copy to clipboard operation
logger copied to clipboard

Feature request: log traceback in addition to error when stop is called

Open DavideMessinaARS opened this issue 3 years ago • 2 comments

I have an algorithm which is divided in various steps, all of them called inside a to_run file.

I want to log not only the errors but the traceback too.

I have written a function that does that:

log_traceback <- function(file_log) {
  file_log <- readLines(file_logfile_log)
  if (substr(tail(file_log, 1), start = 1, stop = 5) == "ERROR"){
    invisible(lapply(.traceback(), log_error))
  }
}

However the function works only when I call it and not when the errors occur.

This means that after each step I would need to call the function which is not ideal for various reasons. (Otherwise the traceback will be overwritten by the next error)

Would it be possible to add an option for logging the traceback inside the log_errors() function? (Or create a log_traceback function)

DavideMessinaARS avatar May 19 '21 07:05 DavideMessinaARS

tryCatchLog does this. https://github.com/aryoda/tryCatchLog

1beb avatar Oct 16 '21 18:10 1beb

Thanks for the feature request! As I am busy with other things, I don't think I have the time to work in this in the coming months, so I would highly appreciate if someone can come up with a PR -- so thus I'm now setting the related "Help wanted" label.

daroczig avatar Feb 29 '24 21:02 daroczig