Skip to content

Commit

Permalink
[#103] Add get-&env, log-env utils (@RickMoynihan)
Browse files Browse the repository at this point in the history
  • Loading branch information
ptaoussanis committed Jun 12, 2015
1 parent eb3b9d5 commit bf2538c
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/taoensso/timbre.cljx
Original file line number Diff line number Diff line change
Expand Up @@ -497,10 +497,24 @@
([config level name expr]
`(log-and-rethrow-errors
(let [result# ~expr]
(log* ~config ~level [~name "=>" result#]) ; Subject to elision
(log* ~config ~level ~name "=>" result#) ; Subject to elision
result# ; NOT subject to elision
))))

(defmacro get-env [] `(zipmap '~(keys &env) [~@(keys &env)]))
(defmacro log-env
"Logs named &env value.
Defaults to :debug logging level and \"&env\" as name."
([ ] `(log-env :debug))
([ level ] `(log-env ~level "&env"))
([ level name] `(log-env *config* ~level ~name))
([config level name] `(log* ~config ~level ~name "=>" (get-env))))

(comment
(macroexpand '(log-env))
(defn foo [x y] (log-env) (+ x y))
(foo 5 10))

#+clj
(defn refer-timbre
"Shorthand for:
Expand Down

0 comments on commit bf2538c

Please sign in to comment.