Skip to content
This repository has been archived by the owner on Jun 17, 2020. It is now read-only.

Commit

Permalink
Let callers decide whether to use (format) in log messages
Browse files Browse the repository at this point in the history
  • Loading branch information
harto committed Feb 3, 2013
1 parent b4d94db commit 7a42148
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
26 changes: 16 additions & 10 deletions common/src/clj/enoki/logging_macros.clj
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
;; A set of macros that defer to implementation-specific logging functions.
;;
;; Implementations must provide the `enoki.logging` namespace, and define a
;; logging function within that namespace that looks like:
;;
;; (fn log* [logger-name level eval-msg-fn])
;;
;; Messages are not evaluated unless the message priority exceeds the relevant
;; logging level.

(ns enoki.logging-macros)

(defmacro log
"Delegates logging to function in implementation-defined namespace."
[level msg args]
`(enoki.logging/log* ~(str *ns*) ~level #(format (str ~msg) ~@args)))
[level msg]
`(enoki.logging/log* ~(str *ns*) ~level #(str ~msg)))

(defmacro debug [msg & args]
`(log :debug ~msg ~args))
(defmacro debug [msg]
`(log :debug ~msg))

(defmacro info [msg & args]
`(log :info ~msg ~args))
(defmacro info [msg]
`(log :info ~msg))

(defmacro warn [msg & args]
`(log :warn ~msg ~args))
(defmacro warn [msg]
`(log :warn ~msg))

(defmacro error [msg & args]
`(log :error ~msg ~args))
(defmacro error [msg]
`(log :error ~msg))
2 changes: 1 addition & 1 deletion swing/src/enoki/graphics/java2d.clj
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
(seesaw/pack! frame)
(seesaw/show! frame))
(.createBufferStrategy canvas 2)
(log/debug "width=%d, height=%d" (.getWidth canvas) (.getHeight canvas)))
(log/debug (format "width=%d, height=%d" (.getWidth canvas) (.getHeight canvas))))

(display-width [_]
(.getWidth canvas))
Expand Down
2 changes: 1 addition & 1 deletion swing/src/enoki/swing.clj
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
(defn- handle-key-event [event-type e]
(if-let [key-name (get key-names (.getKeyCode e))]
(kbd/enqueue-event! event-type key-name)
(log/debug "unprocessable key event (%s): %s" event-type e)))
(log/debug (format "unprocessable key event (%s): %s" event-type e))))

(defn create-frame []
(doto (seesaw/frame :resizable? false)
Expand Down
2 changes: 1 addition & 1 deletion web/src/cljs/enoki/web.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
(do
(kbd/enqueue-event! event-type key-name)
(.preventDefault e))
(log/info "unprocessable key event (%s): %s" event-type (.-keyCode e))))
(log/info (format "unprocessable key event (%s): %s" event-type (.-keyCode e)))))

(defn capture-key-events! [element]
(doto element
Expand Down

0 comments on commit 7a42148

Please sign in to comment.