mirror of https://github.com/status-im/timbre.git
[#171] Add support for appender-level ns filters
This commit is contained in:
parent
5a1a5253e2
commit
ed88597356
|
@ -66,6 +66,8 @@
|
|||
:rate-limit ; [[ncalls-limit window-ms] <...>], or nil
|
||||
:output-fn ; Optional override for inherited (fn [data]) -> string
|
||||
:fn ; (fn [data]) -> side effects, with keys described below
|
||||
:ns-whitelist ; Optional, stacks with active config's whitelist
|
||||
:ns-blacklist ; Optional, stacks with active config's blacklist
|
||||
|
||||
An appender's fn takes a single data map with keys:
|
||||
:config ; Entire config map (this map, etc.)
|
||||
|
@ -212,7 +214,9 @@
|
|||
{:pre [(have? string? ns)]}
|
||||
((compile-ns-filters whitelist blacklist) ns))))
|
||||
|
||||
(comment (qb 10000 (ns-filter ["foo.*"] ["foo.baz"] "foo.bar")))
|
||||
(comment
|
||||
(qb 10000 (ns-filter ["foo.*"] ["foo.baz"] "foo.bar"))
|
||||
(ns-filter nil nil ""))
|
||||
|
||||
#+clj
|
||||
(def ^:private compile-time-ns-filter
|
||||
|
@ -417,6 +421,11 @@
|
|||
(when (and (:enabled? appender)
|
||||
(level>= level (or (:min-level appender) :trace)))
|
||||
|
||||
;; Appender ns filter stacks with main config's ns filter:
|
||||
(when (ns-filter (:ns-whitelist appender)
|
||||
(:ns-blacklist appender)
|
||||
(or ?ns-str ""))
|
||||
|
||||
(let [rate-limit-specs (:rate-limit appender)
|
||||
data-hash-fn (inherit-over :data-hash-fn appender config
|
||||
default-data-hash-fn)
|
||||
|
@ -457,7 +466,7 @@
|
|||
(if-not async?
|
||||
(apfn data) ; Allow errors to throw
|
||||
#+cljs (apfn data)
|
||||
#+clj (send-off (get-agent id) (fn [_] (apfn data)))))))))
|
||||
#+clj (send-off (get-agent id) (fn [_] (apfn data))))))))))
|
||||
nil
|
||||
(:appenders config)))))
|
||||
nil)
|
||||
|
|
Loading…
Reference in New Issue