From b5c998b46bb6e557450949af6f4f01b8730204a8 Mon Sep 17 00:00:00 2001 From: Peter Taoussanis Date: Sun, 19 Feb 2017 02:40:56 +0100 Subject: [PATCH] [#199] More reliable fix for unintended warning output to cljs --- src/taoensso/timbre.cljx | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/taoensso/timbre.cljx b/src/taoensso/timbre.cljx index d429e26..2aab93e 100644 --- a/src/taoensso/timbre.cljx +++ b/src/taoensso/timbre.cljx @@ -186,13 +186,18 @@ ;;;; Combo filtering +#+clj +(defn- compiling-cljs? [] + (when-let [n (find-ns 'cljs.analyzer)] + (when-let [v (ns-resolve n '*cljs-file*)] + @v))) + #+clj (def ^:private compile-time-level (when-let [level (or (enc/read-sys-val "TIMBRE_LEVEL") (enc/read-sys-val "TIMBRE_LOG_LEVEL"))] - (enc/if-clj - (println (str "Compile-time (elision) Timbre level: " level)) - nil) + (when-not (compiling-cljs?) + (println (str "Compile-time (elision) Timbre level: " level))) (let [;; Back compatibility level (if (string? level) (keyword level) level)] @@ -202,16 +207,21 @@ (def ^:private compile-time-ns-filter (if-let [ns-pattern (enc/read-sys-val "TIMBRE_NS_PATTERN")] (do - (enc/if-clj - (println (str "Compile-time (elision) Timbre ns-pattern: " ns-pattern)) - nil) + (when-not (compiling-cljs?) + (println (str "Compile-time (elision) Timbre ns-pattern: " ns-pattern))) + (-compile-ns-filter ns-pattern)) ;; Back compatibility (let [whitelist (have [:or nil? vector?] (enc/read-sys-val "TIMBRE_NS_WHITELIST")) blacklist (have [:or nil? vector?] (enc/read-sys-val "TIMBRE_NS_BLACKLIST"))] - (when whitelist (println (str "Compile-time (elision) Timbre ns whitelist: " whitelist))) - (when blacklist (println (str "Compile-time (elision) Timbre ns blacklist: " blacklist))) + + (when (and whitelist (not (compiling-cljs?))) + (println (str "Compile-time (elision) Timbre ns whitelist: " whitelist))) + + (when (and blacklist (not (compiling-cljs?))) + (println (str "Compile-time (elision) Timbre ns blacklist: " blacklist))) + (-compile-ns-filter whitelist blacklist)))) #+clj ; Called only at macro-expansiom time