[#15]: ">>" "<<" for start/stop logging

This commit is contained in:
anatoly 2015-11-23 10:51:27 -05:00
parent 2d1f77df92
commit 432496863e

View file

@ -18,17 +18,17 @@
(defn whatcha-doing? [{:keys [started? suspended? suspend]} action] (defn whatcha-doing? [{:keys [started? suspended? suspend]} action]
(case action (case action
:up (if suspended? "resuming" :up (if suspended? ">> resuming"
(if-not started? "starting")) (if-not started? ">> starting"))
:down (if (or started? suspended?) "stopping") :down (if (or started? suspended?) "<< stopping")
:suspend (if (and started? suspend) "suspending") :suspend (if (and started? suspend) "<< suspending")
:resume (if suspended? "resuming"))) :resume (if suspended? ">> resuming")))
(defn log-status [f & args] (defn log-status [f & args]
(let [{:keys [ns name] :as state} (second args) (let [{:keys [ns name] :as state} (second args)
action (f-to-action f)] action (f-to-action f)]
(when-let [taking-over-the-world (whatcha-doing? state action)] (when-let [taking-over-the-world (whatcha-doing? state action)]
(info (str ">> " taking-over-the-world ".. " (ns-resolve ns name)))) (info (str taking-over-the-world ".. " (ns-resolve ns name))))
(apply f args))) (apply f args)))
(defonce lifecycle-fns (defonce lifecycle-fns