[#165] Hotfix: don't cache cljs console appender's `js/console`

This commit is contained in:
Peter Taoussanis 2016-05-10 15:19:46 +07:00
parent 2adbabee8d
commit 88bbff347b
1 changed files with 18 additions and 12 deletions

View File

@ -111,24 +111,30 @@
:output-fn :inherit :output-fn :inherit
:fn :fn
(if (and (exists? js/console) js/console.log) (if (and (exists? js/console) js/console.log)
(let [level->logger (let [;; Don't cache this; some libs dynamically replace js/console
{:trace (or js/console.trace js/console.log) level->logger
:debug (or js/console.debug js/console.log) (fn [level]
:info (or js/console.info js/console.log) (or
:warn (or js/console.warn js/console.log) (case level
:error (or js/console.error js/console.log) :trace js/console.trace
:fatal (or js/console.error js/console.log) :debug js/console.debug
:report (or js/console.info js/console.log)}] :info js/console.info
:warn js/console.warn
:error js/console.error
:fatal js/console.error
:report js/console.info)
js/console.log))]
(fn [data] (fn [data]
(let [{:keys [level output-fn vargs_]} data (let [{:keys [level output-fn vargs_]} data
vargs @vargs_ vargs @vargs_
[v1 vnext] (enc/vsplit-first vargs) [v1 vnext] (enc/vsplit-first vargs)
logger (level->logger level js/console.log)] logger (level->logger level)]
(if (or raw-output? (= v1 :timbre/raw)) ; Undocumented (if (or raw-output? (enc/kw-identical? v1 :timbre/raw)) ; Undocumented
(let [output (output-fn (merge data {:msg_ (delay "") (let [output (output-fn (assoc data
:?err_ (delay nil)})) :msg_ (delay "")
:?err_ (delay nil)))
;; [<output> <raw-error> <raw-arg1> <raw-arg2> ...]: ;; [<output> <raw-error> <raw-arg1> <raw-arg2> ...]:
args (->> vnext (cons @(:?err_ data)) (cons output))] args (->> vnext (cons @(:?err_ data)) (cons output))]