Skip to content

Commit

Permalink
[#207] Add docstring for with-context
Browse files Browse the repository at this point in the history
  • Loading branch information
ptaoussanis committed Dec 18, 2016
1 parent d8d667a commit 594e518
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/taoensso/timbre.cljx
Original file line number Diff line number Diff line change
Expand Up @@ -277,13 +277,16 @@

;;;; Internal logging core

(def ^:dynamic *context*
"General-purpose dynamic logging context. Context will be included in
appender data map at logging time."
nil)
(def ^:dynamic *context* "General-purpose dynamic logging context" nil)
(defmacro with-context
"Executes body so that given arbitrary data will be included in the
data map passed to appenders for any enclosed logging calls.
(defmacro with-context [context & body]
`(binding [*context* ~context] ~@body))
(with-context
{:user-name \"Stu\"} ; Will be incl. in data dispatched to appenders
(info \"User request\"))"

[context & body] `(binding [*context* ~context] ~@body))

(defn- next-vargs [v] (if (> (count v) 1) (subvec v 1) []))
(defn- vargs->margs
Expand Down

0 comments on commit 594e518

Please sign in to comment.