[#255] PR housekeeping

This commit is contained in:
Peter Taoussanis 2018-04-15 16:45:31 +02:00
parent 7e87b10441
commit 83139385e7
1 changed files with 14 additions and 11 deletions

View File

@ -238,13 +238,17 @@
(not (string? ns-str-form)) ; Not a compile-time ns-str const (not (string? ns-str-form)) ; Not a compile-time ns-str const
(compile-time-ns-filter ns-str-form))))) (compile-time-ns-filter ns-str-form)))))
(def ns-log-level ;; TODO Also add compile-time support?
(def ^:private ns->?level
"[[<pattern> <level>] ...], ns -> ?level"
(enc/memoize_ (enc/memoize_
(fn [min-level ns-log-level ?ns-str] (fn [ns-log-level ?ns-str]
(or (some (fn [[pattern level]] (enc/rsome
(when (ns-filter [pattern] [] ?ns-str) (fn [[pattern level]]
level)) ns-log-level) (when (ns-filter [pattern] nil ?ns-str) level))
min-level)))) ns-log-level))))
(comment (ns->?level [["taoensso.*" :info]] *ns*))
(defn #+clj may-log? #+cljs ^boolean may-log? (defn #+clj may-log? #+cljs ^boolean may-log?
"Runtime check: would Timbre currently log at the given logging level? "Runtime check: would Timbre currently log at the given logging level?
@ -253,11 +257,10 @@
([level ] (may-log? level nil nil)) ([level ] (may-log? level nil nil))
([level ?ns-str ] (may-log? level ?ns-str nil)) ([level ?ns-str ] (may-log? level ?ns-str nil))
([level ?ns-str ?config] ([level ?ns-str ?config]
(let [config (or ?config *config*) (let [config (or ?config *config*)
min-level (ns-log-level min-level (or (when-let [ns-log-level (get config :ns-log-level)]
(get config :level :report) (ns->?level ns-log-level ?ns-str))
(get config :ns-log-level) (get config :level :report))]
?ns-str)]
(and (and
(level>= level min-level) (level>= level min-level)
(boolean ; Resolves #206 (issue with slf4j-timbre) (boolean ; Resolves #206 (issue with slf4j-timbre)