mirror of
https://github.com/status-im/re-frame.git
synced 2025-02-23 07:18:22 +00:00
CLJC: tools.logging as default re-frame.loggers
This commit is contained in:
parent
b4d915c395
commit
ef3656ff60
13
project.clj
13
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"]
|
||||
|
||||
|
@ -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)
|
||||
#())
|
||||
|
Loading…
x
Reference in New Issue
Block a user