mirror of https://github.com/status-im/timbre.git
Fix #77: compile-time rather than runtime profile namespaced ids
This commit is contained in:
parent
c9b9b4a809
commit
ee49e44a46
|
@ -406,6 +406,9 @@
|
||||||
}))
|
}))
|
||||||
nil))
|
nil))
|
||||||
|
|
||||||
|
(defmacro get-compile-time-ns [] (str *ns*)) ; Nb need `str` to be readable
|
||||||
|
(comment (macroexpand '(get-compile-time-ns)))
|
||||||
|
|
||||||
(defmacro log* "Implementation detail."
|
(defmacro log* "Implementation detail."
|
||||||
{:arglists '([base-appender-args msg-type level & log-args]
|
{:arglists '([base-appender-args msg-type level & log-args]
|
||||||
[base-appender-args msg-type config level & log-args])}
|
[base-appender-args msg-type config level & log-args])}
|
||||||
|
@ -423,7 +426,7 @@
|
||||||
default-config?# (levels-scored s1#)
|
default-config?# (levels-scored s1#)
|
||||||
config# (if default-config?# (get-default-config) s1#)
|
config# (if default-config?# (get-default-config) s1#)
|
||||||
level# (if default-config?# s1# ~s2)
|
level# (if default-config?# s1# ~s2)
|
||||||
compile-time-ns# ~(str *ns*)]
|
compile-time-ns# (get-compile-time-ns)]
|
||||||
;; (println "DEBUG: Runtime level check")
|
;; (println "DEBUG: Runtime level check")
|
||||||
(when (and (level-sufficient? level# config#)
|
(when (and (level-sufficient? level# config#)
|
||||||
(ns-unfiltered? config# compile-time-ns#))
|
(ns-unfiltered? config# compile-time-ns#))
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
(defmacro fq-keyword "Returns namespaced keyword for given id."
|
(defmacro fq-keyword "Returns namespaced keyword for given id."
|
||||||
[id]
|
[id]
|
||||||
`(if (and (keyword? ~id) (namespace ~id)) ~id
|
`(if (and (keyword? ~id) (namespace ~id)) ~id
|
||||||
(keyword (str *ns*) (name ~id))))
|
(keyword (timbre/get-compile-time-ns) (name ~id))))
|
||||||
|
|
||||||
(comment (map #(fq-keyword %) ["foo" :foo :foo/bar]))
|
(comment (map #(fq-keyword %) ["foo" :foo :foo/bar]))
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@
|
||||||
(declare ^:private format-stats)
|
(declare ^:private format-stats)
|
||||||
|
|
||||||
(defmacro with-pdata [level & body]
|
(defmacro with-pdata [level & body]
|
||||||
`(if-not (timbre/logging-enabled? ~level ~(str *ns*))
|
`(if-not (timbre/logging-enabled? ~level (timbre/get-compile-time-ns))
|
||||||
{:result (do ~@body)}
|
{:result (do ~@body)}
|
||||||
(binding [*pdata* (atom {})]
|
(binding [*pdata* (atom {})]
|
||||||
{:result (pspy ::clock-time ~@body)
|
{:result (pspy ::clock-time ~@body)
|
||||||
|
@ -226,7 +226,7 @@
|
||||||
~@body))))
|
~@body))))
|
||||||
|
|
||||||
(comment (defnp foo "Docstring "[x] "boo" (* x x))
|
(comment (defnp foo "Docstring "[x] "boo" (* x x))
|
||||||
(macroexpand '(defnp foo "Docstring "[x] "boo" (* x x)))
|
(macroexpand '(defnp foo "Docstring" [x] "boo" (* x x)))
|
||||||
(profile :info :defnp-test (foo 5)))
|
(profile :info :defnp-test (foo 5)))
|
||||||
|
|
||||||
(comment
|
(comment
|
||||||
|
|
Loading…
Reference in New Issue