Merge branch 'dev'

This commit is contained in:
Peter Taoussanis 2012-10-26 16:28:47 +07:00
commit dafa9293d5
4 changed files with 15 additions and 17 deletions

View File

@ -1,7 +1,7 @@
Current [semantic](http://semver.org/) version:
```clojure
[com.taoensso/timbre "0.8.2"]
[com.taoensso/timbre "0.8.3"]
```
**Breaking changes** since _0.7.x_:
@ -35,7 +35,7 @@ Timbre is an attempt to make **simple logging simple** and more **complex loggin
Timbre is still currently *experimental*. It **has not yet been thoroughly tested in production** and its API is subject to change. To run tests against all supported Clojure versions, use:
```bash
lein2 all test
lein all test
```
## Getting Started
@ -45,7 +45,7 @@ lein2 all test
Depend on Timbre in your `project.clj`:
```clojure
[com.taoensso/timbre "0.8.2"]
[com.taoensso/timbre "0.8.3"]
```
and `use` the library:
@ -255,4 +255,4 @@ I'm also on Twitter: [@ptaoussanis](https://twitter.com/#!/ptaoussanis).
Copyright © 2012 Peter Taoussanis
Distributed under the [Eclipse Public License](http://www.eclipse.org/legal/epl-v10.html), the same as Clojure.
Distributed under the [Eclipse Public License](http://www.eclipse.org/legal/epl-v10.html), the same as Clojure.

View File

@ -1,4 +1,4 @@
(defproject com.taoensso/timbre "0.8.2"
(defproject com.taoensso/timbre "0.8.3"
:description "Simple, flexible, all-Clojure logging. No XML!"
:url "https://github.com/ptaoussanis/timbre"
:license {:name "Eclipse Public License"}

View File

@ -81,15 +81,16 @@
;;;; Define and sort logging levels
(def ^:private ordered-levels [:trace :debug :info :warn :error :fatal :report])
(def ^:private scored-levels (zipmap ordered-levels (range)))
(defn assert-valid-level
[x] (when-not (some #{x} ordered-levels)
(throw (Exception. (str "Invalid logging level: " x)))))
(def ^:private scored-levels (assoc (zipmap ordered-levels (range)) nil 0))
(defn error-level? [x] (boolean (#{:error :fatal} x)))
(defn error-level? [level] (boolean (#{:error :fatal} level)))
(defn- checked-level-score [level]
(or (scored-levels level)
(throw (Exception. (str "Invalid logging level: " level)))))
(def compare-levels
(memoize (fn [x y] (- (scored-levels x) (scored-levels y)))))
(memoize (fn [x y] (- (checked-level-score x) (checked-level-score y)))))
(defn sufficient-level?
[level] (>= (compare-levels level (:current-level @config)) 0))
@ -179,8 +180,7 @@
[level]
(->> (:appenders @config)
(filter #(let [{:keys [enabled? min-level]} (val %)]
(and enabled? (or (nil? min-level)
(>= (compare-levels level min-level) 0)))))
(and enabled? (>= (compare-levels level min-level) 0))))
(into {})))
(comment (relevant-appenders :debug)
@ -241,14 +241,12 @@
"Returns true when current logging level is sufficient and current namespace
is unfiltered."
[level]
(assert-valid-level level)
`(and (sufficient-level? ~level) (@ns-filter-cache ~*ns*)))
(defmacro log*
"Prepares given arguments for, and then dispatches to all relevant
appender-fns."
[level base-args & sigs]
(assert-valid-level level)
`(when-let [juxt-fn# (@appenders-juxt-cache ~level)] ; Any relevant appenders?
(let [[x1# & xs#] (list ~@sigs)
@ -274,7 +272,6 @@
appender-fns. Generic form of standard level-loggers (trace, info, etc.)."
{:arglists '([level message & more] [level throwable message & more])}
[level & sigs]
(assert-valid-level level)
`(when (logging-enabled? ~level)
(log* ~level {} ~@sigs)))
@ -313,6 +310,8 @@
(log :debug (Exception.))
(log :trace "arg1")
(log (or nil :info) "Booya")
(set-config! [:ns-blacklist] [])
(set-config! [:ns-blacklist] ["taoensso.timbre*"])

View File

@ -110,7 +110,6 @@
for db appenders to check for this special key and to log profiling stats to
db in a queryable manner."
[level name & body]
(timbre/assert-valid-level level)
`(if (timbre/logging-enabled? ~level)
(profile*
(fn [name# stats#]