diff --git a/project.clj b/project.clj index 0be2ab8..b005624 100644 --- a/project.clj +++ b/project.clj @@ -7,12 +7,13 @@ [reagent "0.6.0-rc"]] :profiles {:debug {:debug true} - :dev {:dependencies [[karma-reporter "0.3.0"] - [binaryage/devtools "0.7.2"]] - :plugins [[lein-cljsbuild "1.1.3"] - [lein-npm "0.6.2"] - [lein-figwheel "0.5.4-7"] - [lein-shell "0.5.0"]]}} + :dev {:dependencies [[karma-reporter "0.3.0"] + [binaryage/devtools "0.7.2"] + [org.clojure/tools.logging "0.3.1"]] + :plugins [[lein-cljsbuild "1.1.3"] + [lein-npm "0.6.2"] + [lein-figwheel "0.5.4-7"] + [lein-shell "0.5.0"]]}} :clean-targets [:target-path "run/compiled"] diff --git a/src/re_frame/loggers.cljc b/src/re_frame/loggers.cljc index 6e48539..15a01f9 100644 --- a/src/re_frame/loggers.cljc +++ b/src/re_frame/loggers.cljc @@ -1,6 +1,13 @@ (ns re-frame.loggers (:require - [clojure.set :refer [difference]])) + [clojure.set :refer [difference]] + #?@(:clj [[clojure.string :as str] + [clojure.tools.logging :as log]]))) + +(defn log [level & args] + (log/log level (if (= 1 (count args)) + (first args) + (str/join " " (map pr-str args))))) ;; "loggers" holds the current set of logging functions. ;; By default, re-frame uses the functions provided by js/console. @@ -8,15 +15,15 @@ (def ^:private loggers (atom {:log #?(:cljs (js/console.log.bind js/console) - :clj println) + :clj (partial log :info)) :warn #?(:cljs (js/console.warn.bind js/console) - :clj (partial println "WARN: ")) + :clj (partial log :warn)) :error #?(:cljs (js/console.error.bind js/console) - :clj (partial println "ERROR: ")) + :clj (partial log :error)) :group #?(:cljs (if (.-group js/console) ;; console.group does not exist < IE 11 (js/console.group.bind js/console) (js/console.log.bind js/console)) - :clj println) + :clj (partial log :info)) :groupEnd #?(:cljs (if (.-groupEnd js/console) ;; console.groupEnd does not exist < IE 11 (js/console.groupEnd.bind js/console) #())