Merge branch 'dev'

This commit is contained in:
Peter Taoussanis 2013-04-14 16:31:01 +07:00
commit cf0f41dd7d
3 changed files with 15 additions and 16 deletions

View File

@ -1,7 +1,7 @@
Current [semantic](http://semver.org/) version: Current [semantic](http://semver.org/) version:
```clojure ```clojure
[com.taoensso/timbre "1.5.2"] [com.taoensso/timbre "1.5.3"]
``` ```
# Timbre, a (sane) Clojure logging & profiling library # Timbre, a (sane) Clojure logging & profiling library
@ -27,7 +27,7 @@ Timbre is an attempt to make **simple logging simple** and more **complex loggin
Depend on Timbre in your `project.clj`: Depend on Timbre in your `project.clj`:
```clojure ```clojure
[com.taoensso/timbre "1.5.2"] [com.taoensso/timbre "1.5.3"]
``` ```
and `use` the library: and `use` the library:
@ -59,7 +59,7 @@ There's little overhead for checking logging levels:
(time (trace (Thread/sleep 5000))) (time (trace (Thread/sleep 5000)))
%> "Elapsed time: 0.054 msecs" %> "Elapsed time: 0.054 msecs"
(time (when true)) (time (when false))
%> "Elapsed time: 0.051 msecs" %> "Elapsed time: 0.051 msecs"
``` ```
@ -122,7 +122,7 @@ Filter logging output by namespaces:
To enable the standard [Postal](https://github.com/drewr/postal)-based email appender, add the Postal dependency to your `project.clj`: To enable the standard [Postal](https://github.com/drewr/postal)-based email appender, add the Postal dependency to your `project.clj`:
```clojure ```clojure
[com.draines/postal "1.9.1"] [com.draines/postal "1.9.2"]
``` ```
And add the appender to your `ns` declaration: And add the appender to your `ns` declaration:

View File

@ -1,4 +1,4 @@
(defproject com.taoensso/timbre "1.5.2" (defproject com.taoensso/timbre "1.5.3"
:description "Clojure logging & profiling library" :description "Clojure logging & profiling library"
:url "https://github.com/ptaoussanis/timbre" :url "https://github.com/ptaoussanis/timbre"
:license {:name "Eclipse Public License"} :license {:name "Eclipse Public License"}

View File

@ -106,14 +106,14 @@
:append true) :append true)
(catch java.io.IOException _))))}}})) (catch java.io.IOException _))))}}}))
(defn set-config! [[k & ks] val] (swap! config assoc-in (cons k ks) val)) (defn set-config! [ks val] (swap! config assoc-in ks val))
(defn merge-config! [& maps] (apply swap! config utils/deep-merge maps)) (defn merge-config! [& maps] (apply swap! config utils/deep-merge maps))
(defn set-level! [level] (set-config! [:current-level] level)) (defn set-level! [level] (set-config! [:current-level] level))
;;;; Define and sort logging levels ;;;; Define and sort logging levels
(def ^:private ordered-levels [:trace :debug :info :warn :error :fatal :report]) (def ^:private ordered-levels [:trace :debug :info :warn :error :fatal :report])
(def ^:private scored-levels (assoc (zipmap ordered-levels (range)) nil 0)) (def ^:private scored-levels (assoc (zipmap ordered-levels (next (range))) nil 0))
(defn error-level? [level] (boolean (#{:error :fatal} level))) (defn error-level? [level] (boolean (#{:error :fatal} level)))
@ -147,9 +147,8 @@
(let [now (System/currentTimeMillis) (let [now (System/currentTimeMillis)
hash (str ns "/" message) hash (str ns "/" message)
allow? (fn [last-msecs] allow? (fn [last-msecs]
(if last-msecs (or (not last-msecs)
(> (- now last-msecs) max-message-per-msecs) (> (- now last-msecs) max-message-per-msecs)))]
true))]
(when (allow? (@flood-timers hash)) (when (allow? (@flood-timers hash))
(apfn apfn-args) (apfn apfn-args)
@ -187,12 +186,12 @@
(def get-hostname (def get-hostname
(utils/memoize-ttl (utils/memoize-ttl
60000 (fn [] (try (.. java.net.InetAddress getLocalHost getHostName) 60000 (fn [] (try (.. java.net.InetAddress getLocalHost getHostName)
(catch java.net.UnknownHostException e (catch java.net.UnknownHostException _
"UnknownHost"))))) "UnknownHost")))))
(defn- wrap-appender-juxt (defn- wrap-appender-juxt
"Wraps compile-time appender juxt with additional runtime capabilities "Wraps compile-time appender juxt with additional runtime capabilities
(incl. middleware) controller by compile-time config. Like `wrap-appender-fn` (incl. middleware) controlled by compile-time config. Like `wrap-appender-fn`
but operates on the entire juxt at once." but operates on the entire juxt at once."
[juxtfn] [juxtfn]
(->> ; Wrapping applies capabilities bottom-to-top (->> ; Wrapping applies capabilities bottom-to-top
@ -294,11 +293,11 @@
;;;; Define logging macros ;;;; Define logging macros
(defmacro logging-enabled? (defn logging-enabled?
"Returns true when current logging level is sufficient and current namespace "Returns true when current logging level is sufficient and current namespace
is unfiltered." is unfiltered."
[level] [level]
`(and (sufficient-level? ~level) (@ns-filter-cache ~*ns*))) (and (sufficient-level? level) (@ns-filter-cache *ns*)))
(defmacro log* (defmacro log*
"Prepares given arguments for, and then dispatches to all relevant "Prepares given arguments for, and then dispatches to all relevant
@ -314,7 +313,7 @@
{:level ~level {:level ~level
:error? (error-level? ~level) :error? (error-level? ~level)
:instant (Date.) :instant (Date.)
:ns (str ~*ns*) :ns ~(str *ns*)
:message (if has-throwable?# (or (first xs#) x1#) x1#) :message (if has-throwable?# (or (first xs#) x1#) x1#)
:more (if has-throwable?# :more (if has-throwable?#
(conj (vec (rest xs#)) (conj (vec (rest xs#))