mirror of https://github.com/status-im/timbre.git
Fix namespace filtering (mlb-)
This commit is contained in:
parent
ea0f43f03c
commit
b766013031
|
@ -371,13 +371,14 @@
|
|||
|
||||
;;;; Logging macros
|
||||
|
||||
(defn ns-unfiltered? [config & [ns]] ((:ns-filter (compile-config config))
|
||||
(or ns *ns*)))
|
||||
(defn ns-unfiltered? [config ns] ((:ns-filter (compile-config config)) ns))
|
||||
|
||||
(defn logging-enabled? "For 3rd-party utils, etc."
|
||||
[level] (let [config' @config]
|
||||
(and (level-sufficient? level config')
|
||||
(ns-unfiltered? config'))))
|
||||
[level & [compile-time-ns]]
|
||||
(let [config' @config]
|
||||
(and (level-sufficient? level config')
|
||||
(or (nil? compile-time-ns)
|
||||
(ns-unfiltered? config' compile-time-ns)))))
|
||||
|
||||
(defn send-to-appenders! "Implementation detail."
|
||||
[;; Args provided by both Timbre, tools.logging:
|
||||
|
@ -417,10 +418,11 @@
|
|||
s1# ~s1
|
||||
default-config?# (levels-scored s1#)
|
||||
config# (if default-config?# @config s1#)
|
||||
level# (if default-config?# s1# ~s2)]
|
||||
level# (if default-config?# s1# ~s2)
|
||||
compile-time-ns# ~(str *ns*)]
|
||||
;; (println "DEBUG: Runtime level check")
|
||||
(when (and (level-sufficient? level# config#)
|
||||
(ns-unfiltered? config#))
|
||||
(ns-unfiltered? config# compile-time-ns#))
|
||||
(when-let [juxt-fn# (get-in (compile-config config#)
|
||||
[:appenders-juxt level#])]
|
||||
(let [[x1# & xn# :as xs#] (if default-config?#
|
||||
|
@ -432,7 +434,7 @@
|
|||
level#
|
||||
~base-appender-args
|
||||
log-vargs#
|
||||
~(str *ns*)
|
||||
compile-time-ns#
|
||||
(when has-throwable?# x1#)
|
||||
nil ; Timbre generates msg only after middleware
|
||||
juxt-fn#
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
(declare pdata-stats format-pdata)
|
||||
|
||||
(defmacro with-pdata [level & body]
|
||||
`(if-not (timbre/logging-enabled? ~level)
|
||||
`(if-not (timbre/logging-enabled? ~level ~(str *ns*))
|
||||
{:result (do ~@body)}
|
||||
(binding [*pdata* (atom {})]
|
||||
{:result (p ::clock-time ~@body)
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
(ns taoensso.timbre.tools.logging
|
||||
"clojure.tools.logging.impl/Logger implementation"
|
||||
"clojure.tools.logging.impl/Logger implementation.
|
||||
|
||||
Limitations:
|
||||
* No support for zero-overhead compile-time logging levels (`enabled?`
|
||||
called as a fn).
|
||||
* No support for ns filtering (`write!` called as a fn and w/o compile-time
|
||||
ns info).
|
||||
* Limited raw `:args` support (`write!` called w/o raw args)."
|
||||
(:require [clojure.tools.logging]
|
||||
[taoensso.timbre :as timbre]))
|
||||
|
||||
|
@ -8,10 +15,8 @@
|
|||
(enabled? [_ level] (timbre/logging-enabled? level))
|
||||
(write! [_ level throwable message]
|
||||
;; tools.logging message may be a string (for `logp`/`logf` calls) or raw
|
||||
;; argument (for `log` calls). Note that without an :args equivalent for
|
||||
;; `write!`, the best we can do is `[message]`. This inconsistency means
|
||||
;; that :args consumers will necessarily behave differently under
|
||||
;; tools.logging.
|
||||
;; argument (for `log` calls). The best we can do for :args is therefore
|
||||
;; `[message]`:
|
||||
(timbre/send-to-appenders! level {} [message] logger-ns throwable
|
||||
(when (string? message) message))))
|
||||
|
||||
|
|
Loading…
Reference in New Issue