`get-env`: clear primitive (tag) sym metadata

This commit is contained in:
Peter Taoussanis 2015-12-21 21:32:27 +07:00
parent d913721865
commit b09d5611a6
1 changed files with 8 additions and 5 deletions

View File

@ -513,7 +513,13 @@
result# ; NOT subject to elision result# ; NOT subject to elision
)))) ))))
(defmacro get-env [] `(zipmap '~(keys &env) [~@(keys &env)])) (defn- clear-meta [x] (if (meta x) (with-meta x nil) x))
(defmacro get-env [] (let [ks (mapv clear-meta (keys &env))] `(zipmap '~ks [~@ks])))
(comment
(let [x :x] (get-env))
((fn [^long x] (get-env)) 0))
(defmacro log-env (defmacro log-env
"Logs named &env value. "Logs named &env value.
Defaults to :debug logging level and \"&env\" as name." Defaults to :debug logging level and \"&env\" as name."
@ -522,10 +528,7 @@
([ level name] `(log-env *config* ~level ~name)) ([ level name] `(log-env *config* ~level ~name))
([config level name] `(log* ~config ~level ~name "=>" (get-env)))) ([config level name] `(log* ~config ~level ~name "=>" (get-env))))
(comment (comment ((fn foo [x y] (log-env) (+ x y)) 5 10))
(macroexpand '(log-env))
(defn foo [x y] (log-env) (+ x y))
(foo 5 10))
#+clj #+clj
(defn refer-timbre (defn refer-timbre