mirror of
https://github.com/status-im/timbre.git
synced 2025-02-16 13:46:22 +00:00
[#116] Add :context key to appender data (@mikesperber)
This commit is contained in:
parent
b37ace035e
commit
02531eb01f
@ -125,10 +125,9 @@ This is the biggest win over Java logging IMO. Here's `timbre/example-config` (a
|
||||
:output-fn ; (fn [data]) -> formatted output string
|
||||
; (see `default-output-fn` for details)
|
||||
|
||||
:context ; *context* value at log time (see `with-context`)
|
||||
:profile-stats ; From `profile` macro
|
||||
|
||||
Also incl. any `*context*` keys (see `with-context`).
|
||||
|
||||
MIDDLEWARE
|
||||
Middleware are simple (fn [data]) -> ?data fns (applied left->right) that
|
||||
transform the data map dispatched to appender fns. If any middleware returns
|
||||
|
@ -96,10 +96,9 @@
|
||||
:output-fn ; (fn [data]) -> formatted output string
|
||||
; (see `default-output-fn` for details)
|
||||
|
||||
:context ; *context* value at log time (see `with-context`)
|
||||
:profile-stats ; From `profile` macro
|
||||
|
||||
Also incl. any `*context*` keys (see `with-context`).
|
||||
|
||||
MIDDLEWARE
|
||||
Middleware are simple (fn [data]) -> ?data fns (applied left->right) that
|
||||
transform the data map dispatched to appender fns. If any middleware returns
|
||||
@ -298,8 +297,8 @@
|
||||
)
|
||||
|
||||
(def ^:dynamic *context*
|
||||
"General-purpose dynamic logging context. Context will be merged into
|
||||
appender data map at logging time." nil)
|
||||
"General-purpose dynamic logging context. Context will be included in appender
|
||||
data map at logging time." nil)
|
||||
(defmacro with-context [context & body] `(binding [*context* ~context] ~@body))
|
||||
|
||||
(declare get-hostname)
|
||||
@ -327,9 +326,13 @@
|
||||
vargs*_ (delay (vsplit-err1 (force vargs_)))
|
||||
?err_ (delay (get @vargs*_ 0))
|
||||
vargs_ (delay (get @vargs*_ 1))
|
||||
data (merge ?base-data *context*
|
||||
context *context*
|
||||
data (merge ?base-data
|
||||
;; No, better nest than merge (appenders may want to pass
|
||||
;; along arb context w/o knowing context keys, etc.):
|
||||
(when (map? context) context) ; DEPRECATED, for back compat
|
||||
{:config config ; Entire config!
|
||||
;; :context *context* ; Extra destructure's a nuisance
|
||||
:context context
|
||||
:instant instant
|
||||
:level level
|
||||
:?ns-str ?ns-str
|
||||
|
Loading…
x
Reference in New Issue
Block a user