Last active
August 29, 2015 14:22
-
-
Save RickMoynihan/9e64dafe5e9715c2766d to your computer and use it in GitHub Desktop.
Simple timbre logging macro to log the contents of the current lexical environment
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
| (defmacro log-env | |
| ([] `(log-env :info)) | |
| ([level] `(log-env ~level "Captured Environment is")) | |
| ([level message] `(log/log ~level ~message (zipmap (quote ~(keys &env)) [~@(keys &env)])))) |
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
| user> ((fn [a] (let [b 10] (log-env :info "The current lexical environment is:"))) "function argument") | |
| 2015-Jun-12 11:55:12 +0100 mccarthy.lan INFO [user] - The current lexical environment is: {a "function argument", b 10} | |
| ;; => nil |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment