Allow no-message throwable logging, use `str` for ex-data printing

This commit is contained in:
Peter Taoussanis 2013-06-07 20:45:33 +07:00
parent 5d4e5f2739
commit 71218f7086
3 changed files with 10 additions and 8 deletions

View File

@ -1,7 +1,7 @@
Current [semantic](http://semver.org/) version:
```clojure
[com.taoensso/timbre "2.1.1"] ; See commit history for breaking changes since 1.x
[com.taoensso/timbre "2.1.2"] ; See commit history for breaking changes since 1.x
```
# Timbre, a (sane) Clojure logging & profiling library
@ -26,7 +26,7 @@ Logging with Java can be maddeningly, unnecessarily hard. Particularly if all yo
Add the necessary dependency to your [Leiningen](http://leiningen.org/) `project.clj` and `require` the library in your ns:
```clojure
[com.taoensso/timbre "2.1.1"] ; project.clj
[com.taoensso/timbre "2.1.2"] ; project.clj
(ns my-app (:require [taoensso.timbre :as timbre
:refer (trace debug info warn error fatal spy)])) ; ns
```

View File

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

View File

@ -13,7 +13,7 @@
"Like `println` but prints all objects to output stream as a single
atomic string. This is faster and avoids interleaving race conditions."
[& xs]
(print (str (str/join \space xs) \newline))
(print (str/join \space (filter identity xs)) \newline)
(flush))
(defn color-str [color & xs]
@ -40,8 +40,8 @@
(defn stacktrace [throwable & [separator]]
(when throwable
(str separator (when-let [d (ex-data throwable)] (str d " "))
(stacktrace/pst-str throwable))))
(str separator throwable ; (str throwable) incl. ex-data for Clojure 1.4+
"\n\n" (stacktrace/pst-str throwable))))
;;;; Default configuration and appenders
@ -326,14 +326,16 @@
([base-appender-args level log-args message-fn]
`(when-let [juxt-fn# (@appenders-juxt-cache ~level)]
(let [[x1# & xn# :as xs#] (vector ~@log-args)
has-throwable?# (and xn# (instance? Throwable x1#))
has-throwable?# (instance? Throwable x1#)
log-vargs# (vec (if has-throwable?# xn# xs#))]
(log* ~base-appender-args
~level
log-vargs#
~(str *ns*)
(when has-throwable?# x1#)
(when-let [mf# ~message-fn] (apply mf# log-vargs#))
(when-let [mf# ~message-fn]
(when-not (empty? log-vargs#)
(apply mf# log-vargs#)))
juxt-fn#)))))
(defmacro log