#63: goog.log/error for logging cljs errors

This commit is contained in:
anatoly 2017-03-14 00:03:57 -04:00
parent 2f51e5049e
commit 355b9b3ea3
2 changed files with 7 additions and 5 deletions

View file

@ -105,11 +105,11 @@
[state {:keys [stop status] :as current} done] [state {:keys [stop status] :as current} done]
(when (some status #{:started}) (when (some status #{:started})
(if stop (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) (record! state stop done)
:fail? false) :fail? false)
:f-failed)] :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)))
(alter-state! current (NotStartedState. state))) ;; (!) if a state does not have :stop when _should_ this might leak (alter-state! current (NotStartedState. state))) ;; (!) if a state does not have :stop when _should_ this might leak
(swap! running dissoc state) (swap! running dissoc state)

View file

@ -9,10 +9,12 @@
(glog/getLogger "mount")))) (glog/getLogger "mount"))))
#?(:clj #?(:clj
(defn log [msg] (defn log [msg & _]
(prn msg))) (prn msg)))
#?(:cljs #?(:cljs
(defn log [msg] (defn log [msg & level]
(glog/info *logger* msg))) (case (first level)
:error (glog/error *logger* msg)
(glog/info *logger* msg))))