diff --git a/src_cljs/looped_in/content.cljs b/src_cljs/looped_in/content.cljs index a84a894..79485f8 100644 --- a/src_cljs/looped_in/content.cljs +++ b/src_cljs/looped_in/content.cljs @@ -1,16 +1,11 @@ (ns looped-in.content (:require-macros [cljs.core.async.macros :refer [go]]) (:require [ajax.core :refer [GET]] - [cljs.core.async :as async :refer [chan !]])) + [cljs.core.async :as async :refer [chan !]] + [looped-in.logging :as log])) (enable-console-print!) -(defn log [& args] - (apply js/console.log "[Looped In]" args)) - -(defn error [& args] - (apply js/console.error "[Looped In]" args)) - (defn fetch-submission "Fetches submissions from Hacker News by `url`" [url] @@ -20,7 +15,7 @@ "hitsPerPage" 1000 "restrictSearchableAttributes" "url"} :handler (fn [res] (go (>! response-chan res))) - :error-handler (fn [err] (error "Error fetching HN stories:" + :error-handler (fn [err] (log/error "Error fetching HN stories:" (clj->js err)))}) response-chan)) @@ -30,7 +25,7 @@ ;; request and this method for 5 minutes using localStorage [url response] (let [{:strs [hits]} response] - (log "response" response) + (log/debug "response" response) (filter #(= (get % "url") url) hits))) (defn sort-hits @@ -46,7 +41,7 @@ (defn handle-hits "Handles a filtered response" [hits] - (log (clj->js hits)) + (log/debug (clj->js hits)) (let [num-comments (total-num-comments hits)] (-> js/browser (.-runtime) diff --git a/src_cljs/looped_in/logging.cljs b/src_cljs/looped_in/logging.cljs new file mode 100644 index 0000000..296e6ce --- /dev/null +++ b/src_cljs/looped_in/logging.cljs @@ -0,0 +1,13 @@ +(ns looped-in.logging) + +(defn info [& args] + (apply js/console.info "[Looped In]" args)) + +(defn error [& args] + (apply js/console.error "[Looped In]" args)) + +(defn debug [& args] + (apply js/console.debug "[Looped In]" args)) + +(defn warn [& args] + (apply js/console.warn "[Looped In]" args))