mirror of https://github.com/status-im/timbre.git
Merge branch 'dev': v0.8.1
This commit is contained in:
commit
d28429f4f3
|
@ -1,7 +1,7 @@
|
|||
Current [semantic](http://semver.org/) version:
|
||||
|
||||
```clojure
|
||||
[com.taoensso/timbre "0.8.0"]
|
||||
[com.taoensso/timbre "0.8.1"]
|
||||
```
|
||||
|
||||
**Breaking changes** since _0.7.x_:
|
||||
|
@ -45,7 +45,7 @@ lein2 all test
|
|||
Depend on Timbre in your `project.clj`:
|
||||
|
||||
```clojure
|
||||
[com.taoensso/timbre "0.8.0"]
|
||||
[com.taoensso/timbre "0.8.1"]
|
||||
```
|
||||
|
||||
and `use` the library:
|
||||
|
|
10
project.clj
10
project.clj
|
@ -1,4 +1,4 @@
|
|||
(defproject com.taoensso/timbre "0.8.0"
|
||||
(defproject com.taoensso/timbre "0.8.1"
|
||||
:description "Simple, flexible, all-Clojure logging. No XML!"
|
||||
:url "https://github.com/ptaoussanis/timbre"
|
||||
:license {:name "Eclipse Public License"}
|
||||
|
@ -6,15 +6,9 @@
|
|||
[clj-stacktrace "0.2.4"]]
|
||||
:profiles {:1.3 {:dependencies [[org.clojure/clojure "1.3.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 []}
|
||||
: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"]}
|
||||
:min-lein-version "2.0.0"
|
||||
:warn-on-reflection true)
|
|
@ -44,7 +44,7 @@
|
|||
:timestamp-pattern "yyyy-MMM-dd HH:mm:ss ZZ" ; SimpleDateFormat pattern
|
||||
:timestamp-locale nil ; A Locale object, or nil
|
||||
|
||||
;;; Control :prefix format
|
||||
;; Control :prefix format
|
||||
:prefix-fn
|
||||
(fn [{:keys [level timestamp hostname ns]}]
|
||||
(str timestamp " " hostname " " (-> level name str/upper-case)
|
||||
|
@ -233,10 +233,10 @@
|
|||
(defmacro log*
|
||||
"Prepares given arguments for, and then dispatches to all relevant
|
||||
appender-fns."
|
||||
[level base-args & args]
|
||||
[level base-args & sigs]
|
||||
(assert-valid-level level)
|
||||
`(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#)
|
||||
appender-args#
|
||||
|
@ -259,18 +259,19 @@
|
|||
"When logging is enabled, actually logs given arguments with relevant
|
||||
appender-fns. Generic form of standard level-loggers (trace, info, etc.)."
|
||||
{:arglists '([level message & more] [level throwable message & more])}
|
||||
[level & args]
|
||||
[level & sigs]
|
||||
(assert-valid-level level)
|
||||
`(when (logging-enabled? ~level)
|
||||
(log* ~level {} ~@args)))
|
||||
(log* ~level {} ~@sigs)))
|
||||
|
||||
(defmacro spy
|
||||
"Evaluates expression and logs its form and result. Always returns the result.
|
||||
Defaults to :debug logging level."
|
||||
"Evaluates named expression and logs its result. Always returns the result.
|
||||
Defaults to :debug logging level and unevaluated expression as name."
|
||||
([expr] `(spy :debug ~expr))
|
||||
([level expr]
|
||||
([level expr] `(spy ~level '~expr ~expr))
|
||||
([level name expr]
|
||||
`(try
|
||||
(let [result# ~expr] (log ~level '~expr ~expr) result#)
|
||||
(let [result# ~expr] (log ~level ~name ~expr) result#)
|
||||
(catch Exception e#
|
||||
(log ~level '~expr (str "\n" (stacktrace/pst-str e#)))
|
||||
(throw e#)))))
|
||||
|
@ -281,8 +282,8 @@
|
|||
`(defmacro ~(symbol level-name)
|
||||
~(str "Log given arguments at " (str/capitalize level-name) " level.")
|
||||
~'{:arglists '([message & more] [throwable message & more])}
|
||||
[& args#]
|
||||
`(log ~~level ~@args#))))
|
||||
[& sigs#]
|
||||
`(log ~~level ~@sigs#))))
|
||||
|
||||
(defmacro ^:private def-loggers
|
||||
[] `(do ~@(map (fn [level] `(def-logger ~level)) ordered-levels)))
|
||||
|
@ -306,5 +307,6 @@
|
|||
(time (dotimes [n 10000] (trace "This won't log"))) ; Overhead 5ms/10ms
|
||||
(time (dotimes [n 5] (info "foo" "bar")))
|
||||
(spy (* 6 5 4 3 2 1))
|
||||
(spy :debug :factorial6 (* 6 5 4 3 2 1))
|
||||
(info (Exception. "noes!") "bar")
|
||||
(spy (/ 4 0)))
|
Loading…
Reference in New Issue