Skip to content

Commit

Permalink
NB Refactor appenders API, implementation
Browse files Browse the repository at this point in the history
Appender arg changes:
  - REMOVED: :data-output-fn, :hash-arg_
  - Deprecated: :?err_, :vargs_ (no point in delaying these now)
  - New: :?err, :vargs, :?msg-fmt, :hash_, :output_, :?meta

Implementation notes:
  - Have unified all vargs processing during margs phase
  - vargs no longer contains message format; now extracted as separate :?msg-fmt
  - :output-fn and :timezone_ are now cached between appenders when possible
  - :output_ now provides a convenient, cache-aware way of getting formatted ouput
  - Hash stuff is now non-configurable but far more predictable; if appenders
    have specific needs beyond :hash_, they should use a custom (fn [data]).
  • Loading branch information
ptaoussanis committed Jun 23, 2016
1 parent 02c8fef commit e5b95cb
Show file tree
Hide file tree
Showing 2 changed files with 236 additions and 204 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,33 +121,33 @@ This is the biggest win over Java logging IMO. **All** of Timbre's behaviour is
An appender is a map with keys:
:min-level ; Level keyword, or nil (=> no minimum level)
:enabled? ;
:async? ; Dispatch using agent? Useful for slow appenders
:async? ; Dispatch using agent? Useful for slow appenders (clj only)
:rate-limit ; [[ncalls-limit window-ms] <...>], or nil
:output-fn ; Optional override for inherited (fn [data]) -> string
:fn ; (fn [data]) -> side effects, with keys described below
:timestamp-opts ; Optional override for inherited {:pattern _ :locale _ :timezone _}
:ns-whitelist ; Optional, stacks with active config's whitelist
:ns-blacklist ; Optional, stacks with active config's blacklist
:fn ; (fn [data]) -> side effects, with keys described below
An appender's fn takes a single data map with keys:
:config ; Entire config map (this map, etc.)
:appender-id ; Id of appender currently dispatching
:appender ; Entire map of appender currently dispatching
:instant ; Platform date (java.util.Date or js/Date)
:level ; Keyword
:error-level? ; Is level e/o #{:error :fatal}?
:?ns-str ; String, or nil
:?file ; String, or nil
:?line ; Integer, or nil ; Waiting on CLJ-865
:?err_ ; Delay - first-arg platform error, or nil
:vargs_ ; Delay - raw args vector
:hostname_ ; Delay - string (clj only)
:msg_ ; Delay - args string
:timestamp_ ; Delay - string
:?err ; First-arg platform error, or nil
:vargs ; Vector of raw args
:output_ ; Forceable - final formatted output string created
; by calling (output-fn <this-data-map>)
:msg_ ; Forceable - args as a string
:timestamp_ ; Forceable - string
:hostname_ ; Forceable - string (clj only)
: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
Expand Down

0 comments on commit e5b95cb

Please sign in to comment.