From 5563bc8e648845d6019874b9c7da7342f1cfce90 Mon Sep 17 00:00:00 2001 From: Peter Taoussanis Date: Fri, 11 Mar 2016 13:13:14 +0700 Subject: [PATCH] Add example appender ns --- src/taoensso/timbre/appenders/core.cljx | 45 -------------- src/taoensso/timbre/appenders/example.clj | 74 +++++++++++++++++++++++ 2 files changed, 74 insertions(+), 45 deletions(-) create mode 100644 src/taoensso/timbre/appenders/example.clj diff --git a/src/taoensso/timbre/appenders/core.cljx b/src/taoensso/timbre/appenders/core.cljx index 47c5039..acdcb7a 100644 --- a/src/taoensso/timbre/appenders/core.cljx +++ b/src/taoensso/timbre/appenders/core.cljx @@ -14,51 +14,6 @@ ;; TODO Add a simple official rolling spit appender? -;;;; Example appender ---> (COPY THIS TO MAKE YOUR OWN APPENDER) <--- - -#_ -(defn example-appender - "Docstring to explain any special opts to influence appender construction, - etc. Returns the appender map." - [& [{:keys [] :as opts}]] - - {:enabled? true ; Please enable by default - :async? false ; Use agent for appender dispatch? Useful for slow dispatch. - :min-level nil ; nil (no min level), or min logging level keyword - ;; :rate-limit nil - :rate-limit [[5 (enc/ms :mins 1)] ; 5 calls/min - [100 (enc/ms :hours 1)] ; 100 calls/hour - ] - - :output-fn :inherit ; or a custom (fn [data]) -> string - :fn - (fn [data] - (let [;; See `timbre/example-config` for info on all available args: - {:keys [instant level ?err_ vargs_ output-fn - config ; Entire Timbre config map in effect - appender ; Entire appender map in effect - ]} - data - - ?err @?err_ ; ?err non-nil iff first given arg was an error - vargs @vargs_ ; Vector of raw args (excl. possible first error) - - ;; You'll often want an output string with ns, timestamp, vargs, etc. - ;; A (fn [data]) -> string formatter is provided under the :output-fn - ;; key, defined as: - ;; `(or (:output-fn ) - ;; (:output-fn string + + ;; The actual appender (fn [data-map]) -> possible side effects + :fn + (fn [data-map] + (let [;; See `timbre/example-config` for info on all available keys: + {:keys [instant level ?err_ vargs_ output-fn + config ; Entire Timbre config map in effect + appender ; Entire appender map in effect + ]} + data-map + + ?err @?err_ ; An error, or nil + vargs @vargs_ ; Vector of raw logging args + + ;; You'll often want an output string with ns, timestamp, vargs, etc. + ;; A (fn [data]) -> string formatter is provided under the :output-fn + ;; key, defined as: + ;; `(or (:output-fn ) + ;; (:output-fn