mirror of
https://github.com/status-im/timbre.git
synced 2025-02-10 10:46:32 +00:00
thread-configurable logging
This commit is contained in:
parent
a834e0684a
commit
6af185f28a
@ -397,6 +397,11 @@
|
|||||||
}))
|
}))
|
||||||
nil))
|
nil))
|
||||||
|
|
||||||
|
(def ^:dynamic *config-dynamic* nil)
|
||||||
|
(defmacro with-logging-config
|
||||||
|
"Allows thread-local logging config override. Useful for dev & testing."
|
||||||
|
[config & body] `(binding [*config-dynamic* ~config] ~@body))
|
||||||
|
|
||||||
(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])}
|
||||||
@ -412,7 +417,7 @@
|
|||||||
`(let [;;; Support [level & log-args], [config level & log-args] sigs:
|
`(let [;;; Support [level & log-args], [config level & log-args] sigs:
|
||||||
s1# ~s1
|
s1# ~s1
|
||||||
default-config?# (levels-scored s1#)
|
default-config?# (levels-scored s1#)
|
||||||
config# (if default-config?# @config s1#)
|
config# (if default-config?# (or *config-dynamic* @config) s1#)
|
||||||
level# (if default-config?# s1# ~s2)
|
level# (if default-config?# s1# ~s2)
|
||||||
compile-time-ns# ~(str *ns*)]
|
compile-time-ns# ~(str *ns*)]
|
||||||
;; (println "DEBUG: Runtime level check")
|
;; (println "DEBUG: Runtime level check")
|
||||||
@ -495,7 +500,8 @@
|
|||||||
'[taoensso.timbre :as timbre
|
'[taoensso.timbre :as timbre
|
||||||
:refer (log trace debug info warn error fatal report
|
:refer (log trace debug info warn error fatal report
|
||||||
logf tracef debugf infof warnf errorf fatalf reportf
|
logf tracef debugf infof warnf errorf fatalf reportf
|
||||||
spy logged-future with-log-level sometimes)])
|
spy logged-future with-log-level with-logging-config
|
||||||
|
sometimes)])
|
||||||
(require
|
(require
|
||||||
'[taoensso.timbre.profiling :as profiling
|
'[taoensso.timbre.profiling :as profiling
|
||||||
:refer (pspy pspy* profile defnp p p*)])"
|
:refer (pspy pspy* profile defnp p p*)])"
|
||||||
@ -504,7 +510,8 @@
|
|||||||
'[taoensso.timbre :as timbre
|
'[taoensso.timbre :as timbre
|
||||||
:refer (log trace debug info warn error fatal report
|
:refer (log trace debug info warn error fatal report
|
||||||
logf tracef debugf infof warnf errorf fatalf reportf
|
logf tracef debugf infof warnf errorf fatalf reportf
|
||||||
spy logged-future with-log-level sometimes)])
|
spy logged-future with-log-level with-logging-config
|
||||||
|
sometimes)])
|
||||||
(require
|
(require
|
||||||
'[taoensso.timbre.profiling :as profiling
|
'[taoensso.timbre.profiling :as profiling
|
||||||
:refer (pspy pspy* profile defnp p p*)]))
|
:refer (pspy pspy* profile defnp p p*)]))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user