From 355b9b3ea3d862b1de9dc8a7c6aeb02b37ac1f2c Mon Sep 17 00:00:00 2001 From: anatoly Date: Tue, 14 Mar 2017 00:03:57 -0400 Subject: [PATCH] #63: goog.log/error for logging cljs errors --- src/mount/core.cljc | 4 ++-- src/mount/tools/logger.cljc | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/mount/core.cljc b/src/mount/core.cljc index c2750a5..e5e91c1 100644 --- a/src/mount/core.cljc +++ b/src/mount/core.cljc @@ -105,11 +105,11 @@ [state {:keys [stop status] :as current} done] (when (some status #{:started}) (if stop - (if-let [error (-> (on-error (str "could not stop [" state "] due to") + (if-let [cause (-> (on-error (str "could not stop [" state "] due to") (record! state stop done) :fail? false) :f-failed)] - (log error) ;; this would mostly be useful in REPL + (log cause :error) ;; this would mostly be useful in REPL / browser console (alter-state! current (NotStartedState. state))) (alter-state! current (NotStartedState. state))) ;; (!) if a state does not have :stop when _should_ this might leak (swap! running dissoc state) diff --git a/src/mount/tools/logger.cljc b/src/mount/tools/logger.cljc index 1644264..f862cf8 100644 --- a/src/mount/tools/logger.cljc +++ b/src/mount/tools/logger.cljc @@ -9,10 +9,12 @@ (glog/getLogger "mount")))) #?(:clj - (defn log [msg] + (defn log [msg & _] (prn msg))) #?(:cljs - (defn log [msg] - (glog/info *logger* msg))) + (defn log [msg & level] + (case (first level) + :error (glog/error *logger* msg) + (glog/info *logger* msg))))