Last active
February 5, 2018 19:21
-
-
Save vyzo/ec2e6eb64e806085efeef7a645dda3df to your computer and use it in GitHub Desktop.
log/caller
This file contains 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
(def (get-caller cont) | |
(let lp ((cont cont)) | |
(and cont | |
(or (##continuation-creator cont) | |
(lp (##continuation-next-frame cont #f)))))) | |
(def (log/caller fmt . args) | |
(continuation-capture | |
(lambda (cont) | |
(let (caller (get-caller cont)) | |
(when caller | |
(display (or (##procedure-friendly-name caller) '?)) | |
(display ": ")) | |
(apply printf fmt args))))) | |
(def (foo) | |
(log/caller "hello world~n") | |
(void)) ; inhibit tail context | |
> (foo) | |
foo: hello world |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment