Housekeeping

This commit is contained in:
Peter Taoussanis 2012-08-02 14:59:58 +07:00
parent 6596919615
commit edf2a13817
2 changed files with 8 additions and 14 deletions

View File

@ -6,15 +6,9 @@
[clj-stacktrace "0.2.4"]] [clj-stacktrace "0.2.4"]]
:profiles {:1.3 {:dependencies [[org.clojure/clojure "1.3.0"]]} :profiles {:1.3 {:dependencies [[org.clojure/clojure "1.3.0"]]}
:1.4 {:dependencies [[org.clojure/clojure "1.4.0"]]} :1.4 {:dependencies [[org.clojure/clojure "1.4.0"]]}
:1.5 {:dependencies [[org.clojure/clojure "1.5.0-master-SNAPSHOT"]]} :1.5 {:dependencies [[org.clojure/clojure "1.5.0-alpha3"]]}
:dev {:dependencies []} :dev {:dependencies []}
:test {:dependencies []}} :test {:dependencies []}}
:repositories {"sonatype" {:url "http://oss.sonatype.org/content/repositories/releases"
:snapshots false
:releases {:checksum :fail :update :always}}
"sonatype-snapshots" {:url "http://oss.sonatype.org/content/repositories/snapshots"
:snapshots true
:releases {:checksum :fail :update :always}}}
:aliases {"test-all" ["with-profile" "test,1.3:test,1.4:test,1.5" "test"]} :aliases {"test-all" ["with-profile" "test,1.3:test,1.4:test,1.5" "test"]}
:min-lein-version "2.0.0" :min-lein-version "2.0.0"
:warn-on-reflection true) :warn-on-reflection true)

View File

@ -44,7 +44,7 @@
:timestamp-pattern "yyyy-MMM-dd HH:mm:ss ZZ" ; SimpleDateFormat pattern :timestamp-pattern "yyyy-MMM-dd HH:mm:ss ZZ" ; SimpleDateFormat pattern
:timestamp-locale nil ; A Locale object, or nil :timestamp-locale nil ; A Locale object, or nil
;;; Control :prefix format ;; Control :prefix format
:prefix-fn :prefix-fn
(fn [{:keys [level timestamp hostname ns]}] (fn [{:keys [level timestamp hostname ns]}]
(str timestamp " " hostname " " (-> level name str/upper-case) (str timestamp " " hostname " " (-> level name str/upper-case)
@ -233,10 +233,10 @@
(defmacro log* (defmacro log*
"Prepares given arguments for, and then dispatches to all relevant "Prepares given arguments for, and then dispatches to all relevant
appender-fns." appender-fns."
[level base-args & args] [level base-args & sigs]
(assert-valid-level level) (assert-valid-level level)
`(when-let [juxt-fn# (@appenders-juxt-cache ~level)] ; Any relevant appenders? `(when-let [juxt-fn# (@appenders-juxt-cache ~level)] ; Any relevant appenders?
(let [[x1# & xs#] (list ~@args) (let [[x1# & xs#] (list ~@sigs)
has-throwable?# (instance? Throwable x1#) has-throwable?# (instance? Throwable x1#)
appender-args# appender-args#
@ -259,10 +259,10 @@
"When logging is enabled, actually logs given arguments with relevant "When logging is enabled, actually logs given arguments with relevant
appender-fns. Generic form of standard level-loggers (trace, info, etc.)." appender-fns. Generic form of standard level-loggers (trace, info, etc.)."
{:arglists '([level message & more] [level throwable message & more])} {:arglists '([level message & more] [level throwable message & more])}
[level & args] [level & sigs]
(assert-valid-level level) (assert-valid-level level)
`(when (logging-enabled? ~level) `(when (logging-enabled? ~level)
(log* ~level {} ~@args))) (log* ~level {} ~@sigs)))
(defmacro spy (defmacro spy
"Evaluates expression and logs its form and result. Always returns the result. "Evaluates expression and logs its form and result. Always returns the result.
@ -281,8 +281,8 @@
`(defmacro ~(symbol level-name) `(defmacro ~(symbol level-name)
~(str "Log given arguments at " (str/capitalize level-name) " level.") ~(str "Log given arguments at " (str/capitalize level-name) " level.")
~'{:arglists '([message & more] [throwable message & more])} ~'{:arglists '([message & more] [throwable message & more])}
[& args#] [& sigs#]
`(log ~~level ~@args#)))) `(log ~~level ~@sigs#))))
(defmacro ^:private def-loggers (defmacro ^:private def-loggers
[] `(do ~@(map (fn [level] `(def-logger ~level)) ordered-levels))) [] `(do ~@(map (fn [level] `(def-logger ~level)) ordered-levels)))