Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove trailing spaces from console logging #200

Merged
merged 1 commit into from
Aug 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/re_frame/events.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
(make-chain interceptors)
(do ;; do a whole lot of development time checks
(when-not (coll? interceptors)
(console :error "re-frame: when registering " id ", expected a collection of interceptors, got: " interceptors))
(console :error (str "re-frame: when registering " id ", expected a collection of interceptors, got:") interceptors))
(let [chain (make-chain interceptors)]
(when (empty? chain)
(console :error "re-frame: when registering " id ", given an empty interceptor chain"))
(console :error (str "re-frame: when registering" id ", given an empty interceptor chain")))
(when-let [not-i (first (remove interceptor/interceptor? chain))]
(if (fn? not-i)
(console :error "re-frame: when registering " id ", got a function instead of an interceptor. Did you provide old style middleware by mistake? Got: " not-i)
(console :error "re-frame: when registering " id ", expected interceptors, but got: " not-i)))
(console :error (str "re-frame: when registering " id ", got a function instead of an interceptor. Did you provide old style middleware by mistake? Got:") not-i)
(console :error (str "re-frame: when registering " id ", expected interceptors, but got:") not-i)))
chain)))))


Expand All @@ -54,7 +54,7 @@
(let [event-id (first-in-vector event-v)]
(if-let [interceptors (get-handler kind event-id true)]
(if *handling*
(console :error "re-frame: while handling \"" *handling* "\" dispatch-sync was called for \"" event-v "\". You can't call dispatch-sync within an event handler.")
(console :error (str "re-frame: while handling \"" *handling* "\", dispatch-sync was called for \"" event-v "\". You can't call dispatch-sync within an event handler."))
(binding [*handling* event-v]
(interceptor/execute event-v interceptors))))))

Expand Down
6 changes: 3 additions & 3 deletions src/re_frame/fx.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
(fn [value]
(doseq [{:keys [ms dispatch] :as effect} value]
(if (or (empty? dispatch) (-> ms number? not))
(console :error "re-frame: ignoring bad :dispatch-later value: " effect)
(console :error "re-frame: ignoring bad :dispatch-later value:" effect)
(set-timeout! #(router/dispatch dispatch) ms)))))


Expand All @@ -71,7 +71,7 @@
:dispatch
(fn [value]
(if-not (vector? value)
(console :error "re-frame: ignoring bad :dispatch value. Expected a vector, but got: " value)
(console :error "re-frame: ignoring bad :dispatch value. Expected a vector, but got:" value)
(router/dispatch value))))


Expand All @@ -87,7 +87,7 @@
:dispatch-n
(fn [value]
(if-not (sequential? value)
(console :error "re-frame: ignoring bad :dispatch-n value. Expected a collection, got got: " value))
(console :error "re-frame: ignoring bad :dispatch-n value. Expected a collection, got got:" value))
(doseq [event value] (router/dispatch event))))


Expand Down
2 changes: 1 addition & 1 deletion src/re_frame/interceptor.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
(if-let [unknown-keys (seq (clojure.set/difference
(-> (dissoc m :name) keys set) ;; XXX take out name in due course
mandatory-interceptor-keys))]
(console :error "re-frame: ->interceptor " m " has unknown keys: " unknown-keys)))
(console :error "re-frame: ->interceptor " m " has unknown keys:" unknown-keys)))
{:id (or id name :unnamed) ;; XXX remove `name` in due course
:before before
:after after })
Expand Down
6 changes: 3 additions & 3 deletions src/re_frame/registrar.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
(let [handler (get-handler kind id)]
(when debug-enabled?
(when (and required? (nil? handler))
(console :error "re-frame: no " (str kind) " handler registered for: " id)))
(console :error "re-frame: no " (str kind) " handler registered for:" id)))
handler)))


(defn register-handler
[kind id handler-fn]
(when debug-enabled?
(when (get-handler kind id false)
(console :warn "re-frame: overwriting " (str kind) " handler for: " id))) ;; allow it, but warn. Happens on figwheel reloads.
(console :warn "re-frame: overwriting" (str kind) "handler for:" id))) ;; allow it, but warn. Happens on figwheel reloads.
(swap! kind->id->handler assoc-in [kind id] handler-fn)
handler-fn) ;; note: returns the just registered handler

Expand All @@ -53,4 +53,4 @@
(assert (kinds kind))
(if (get-handler kind id)
(swap! kind->id->handler update-in [kind] dissoc id)
(console :warn "re-frame: can't clear " (str kind) " handler for " id ". Not found."))))
(console :warn "re-frame: can't clear" (str kind) "handler for" (str id ". Handler not found.")))))
4 changes: 2 additions & 2 deletions src/re_frame/router.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@
;; register a callback function which will be called after each event is processed
(add-post-event-callback [_ id callback-fn]
(if (contains? post-event-callback-fns id)
(console :warn "re-frame: overwriting existing post event call back with id: " id))
(console :warn "re-frame: overwriting existing post event call back with id:" id))
(->> (assoc post-event-callback-fns id callback-fn)
(set! post-event-callback-fns)))

(remove-post-event-callback [_ id]
(if-not (contains? post-event-callback-fns id)
(console :warn "re-frame: could not remove post event call back with id: " id)
(console :warn "re-frame: could not remove post event call back with id:" id)
(->> (dissoc post-event-callback-fns id)
(set! post-event-callback-fns))))

Expand Down
12 changes: 6 additions & 6 deletions src/re_frame/std_interceptors.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,23 @@
:id :debug
:before (fn debug-before
[context]
(console :log "Handling re-frame event: " (get-coeffect context :event))
(console :log "Handling re-frame event:" (get-coeffect context :event))
context)
:after (fn debug-after
[context]
(let [event (get-coeffect context :event)
orig-db (get-coeffect context :db)
new-db (get-effect context :db ::not-found)]
(if (= new-db ::not-found)
(console :log "No :db changes caused by: " event)
(console :log "No :db changes caused by:" event)
(let [[only-before only-after] (data/diff orig-db new-db)
db-changed? (or (some? only-before) (some? only-after))]
(if db-changed?
(do (console :group "db clojure.data/diff for: " event)
(console :log "only before: " only-before)
(console :log "only after : " only-after)
(do (console :group "db clojure.data/diff for:" event)
(console :log "only before:" only-before)
(console :log "only after :" only-after)
(console :groupEnd))
(console :log "no app-db changes caused by: " event))))
(console :log "no app-db changes caused by:" event))))
context))))


Expand Down
12 changes: 6 additions & 6 deletions src/re_frame/subs.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
(let [cache-key [query-v dynv]]
;; when this reaction is nolonger being used, remove it from the cache
(add-on-dispose! r #(do (swap! query->reaction dissoc cache-key)
#_(console :log "Removing subscription: " cache-key)))
#_(console :log "Removing subscription:" cache-key)))
;; cache this reaction, so it can be used to deduplicate other, later "=" subscriptions
(swap! query->reaction assoc cache-key r)
r)) ;; return the actual reaction
Expand All @@ -60,7 +60,7 @@
handler-fn (get-handler kind query-id)]
;(console :log "Subscription created: " query-v)
(if-not handler-fn
(console :error "re-frame: no subscription handler registered for: \"" query-id "\". Returning a nil subscription."))
(console :error (str "re-frame: no subscription handler registered for: \"" query-id "\". Returning a nil subscription.")))
(cache-and-return query-v [] (handler-fn app-db query-v)))))

([v dynv]
Expand All @@ -71,9 +71,9 @@
handler-fn (get-handler kind query-id)]
(when debug-enabled?
(when-let [not-reactive (not-empty (remove ratom? dynv))]
(console :warn "re-frame: your subscription's dynamic parameters that don't implement IReactiveAtom: " not-reactive)))
(console :warn "re-frame: your subscription's dynamic parameters that don't implement IReactiveAtom:" not-reactive)))
(if (nil? handler-fn)
(console :error "re-frame: no subscription handler registered for: \"" query-id "\". Returning a nil subscription.")
(console :error (str "re-frame: no subscription handler registered for: \"" query-id "\". Returning a nil subscription."))
(let [dyn-vals (make-reaction (fn [] (mapv deref dynv)))
sub (make-reaction (fn [] (handler-fn app-db v @dyn-vals)))]
;; handler-fn returns a reaction which is then wrapped in the sub reaction
Expand Down Expand Up @@ -144,7 +144,7 @@
;; a single `inputs` fn
1 (let [f (first input-args)]
(when-not (fn? f)
(console :error err-header "2nd argument expected to be an inputs function, got: " f))
(console :error err-header "2nd argument expected to be an inputs function, got:" f))
f)

;; one sugar pair
Expand All @@ -158,7 +158,7 @@
vecs (map last pairs)
ret-val (map subscribe vecs)]
(when-not (every? vector? vecs)
(console :error err-header "expected pairs of :<- and vectors, got: " pairs))
(console :error err-header "expected pairs of :<- and vectors, got:" pairs))
(fn inp-fn
([_] ret-val)
([_ _] ret-val))))]
Expand Down
2 changes: 1 addition & 1 deletion src/re_frame/utils.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
[v]
(if (vector? v)
(first v)
(console :error "re-frame: expected a vector, but got: " v)))
(console :error "re-frame: expected a vector, but got:" v)))