Created
September 15, 2025 16:11
-
-
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:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| % 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