Skip to content

Instantly share code, notes, and snippets.

@infotroph
Created September 15, 2025 16:11
Show Gist options
  • Select an option

  • Save infotroph/cd9a5eae82973b55aad21cf785017628 to your computer and use it in GitHub Desktop.

Select an option

Save infotroph/cd9a5eae82973b55aad21cf785017628 to your computer and use it in GitHub Desktop.
Proof of concept for using global calling handlers to set up PEcAn logging of the messages from bog-standard stop/warning/message calls:
% Rscript -e 'x<-function(msg)PEcAn.logger::logger.severe(msg); x("oh no")'
2025-03-25 12:30:30.012505 SEVERE [x] : oh no
Error in PEcAn.logger::logger.severe(msg) : oh no
Calls: x -> <Anonymous>
Execution halted
% Rscript -e 'x<-function(msg)stop(msg); x("oh no")'
Error in x("oh no") : oh no
Execution halted
% Rscript -e 'globalCallingHandlers(error = PEcAn.logger::logger.severe); x<-function(msg)stop(msg); x("oh no")'
2025-03-25 12:31:12.770117 SEVERE [h] : oh no x("oh no")
Error in h(simpleError(msg, call)) : Error in x("oh no"): oh no
Calls: x
Execution halted
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment