mirror of https://github.com/status-im/timbre.git
Make it more obvious how to disable stacktrace fonts
This commit is contained in:
parent
63e805560f
commit
6bcf5135d0
|
@ -123,6 +123,7 @@ This is the biggest win over Java logging IMO. Here's `timbre/example-config` (a
|
||||||
:msg_ ; Delay - args string
|
:msg_ ; Delay - args string
|
||||||
:timestamp_ ; Delay - string
|
:timestamp_ ; Delay - string
|
||||||
:output-fn ; (fn [data]) -> formatted output string
|
:output-fn ; (fn [data]) -> formatted output string
|
||||||
|
; (see `default-output-fn` for details)
|
||||||
|
|
||||||
:profile-stats ; From `profile` macro
|
:profile-stats ; From `profile` macro
|
||||||
|
|
||||||
|
|
|
@ -41,11 +41,12 @@
|
||||||
:timezone (java.util.TimeZone/getDefault)})
|
:timezone (java.util.TimeZone/getDefault)})
|
||||||
|
|
||||||
(declare stacktrace)
|
(declare stacktrace)
|
||||||
(defn default-output-fn "(fn [data]) -> string output."
|
(defn default-output-fn
|
||||||
|
"Default (fn [data]) -> string output fn.
|
||||||
|
You can modify default options with `(partial default-output-fn <opts-map>)`."
|
||||||
([data] (default-output-fn nil data))
|
([data] (default-output-fn nil data))
|
||||||
([opts data] ; Allow partials for common modified fns
|
([{:keys [no-stacktrace? stacktrace-fonts] :as opts} data]
|
||||||
(let [{:keys [level ?err_ vargs_ msg_ ?ns-str hostname_ timestamp_]} data
|
(let [{:keys [level ?err_ vargs_ msg_ ?ns-str hostname_ timestamp_]} data]
|
||||||
{:keys [no-stacktrace?]} opts]
|
|
||||||
(str
|
(str
|
||||||
#+clj (force timestamp_) #+clj " "
|
#+clj (force timestamp_) #+clj " "
|
||||||
#+clj (force hostname_) #+clj " "
|
#+clj (force hostname_) #+clj " "
|
||||||
|
@ -93,6 +94,7 @@
|
||||||
:msg_ ; Delay - args string
|
:msg_ ; Delay - args string
|
||||||
:timestamp_ ; Delay - string
|
:timestamp_ ; Delay - string
|
||||||
:output-fn ; (fn [data]) -> formatted output string
|
:output-fn ; (fn [data]) -> formatted output string
|
||||||
|
; (see `default-output-fn` for details)
|
||||||
|
|
||||||
:profile-stats ; From `profile` macro
|
:profile-stats ; From `profile` macro
|
||||||
|
|
||||||
|
@ -560,14 +562,17 @@
|
||||||
|
|
||||||
(comment (get-hostname))
|
(comment (get-hostname))
|
||||||
|
|
||||||
(defn stacktrace [err & [opts]]
|
(defn stacktrace [err & [{:keys [stacktrace-fonts] :as opts}]]
|
||||||
#+cljs (str err) ; TODO Alternatives?
|
#+cljs (str err) ; TODO Alternatives?
|
||||||
#+clj
|
#+clj
|
||||||
(if-let [fonts (:stacktrace-fonts opts)]
|
(let [stacktrace-fonts (if (and (nil? stacktrace-fonts)
|
||||||
(binding [aviso-ex/*fonts* fonts] (aviso-ex/format-exception err))
|
(contains? opts :stacktrace-fonts))
|
||||||
(aviso-ex/format-exception err)))
|
{} stacktrace-fonts)]
|
||||||
|
(if-let [fonts stacktrace-fonts]
|
||||||
|
(binding [aviso-ex/*fonts* fonts] (aviso-ex/format-exception err))
|
||||||
|
(aviso-ex/format-exception err))))
|
||||||
|
|
||||||
(comment (stacktrace (Exception. "Boo") {:stacktrace-fonts {}}))
|
(comment (stacktrace (Exception. "Boo") {:stacktrace-fonts nil}))
|
||||||
|
|
||||||
(defmacro sometimes "Handy for sampled logging, etc."
|
(defmacro sometimes "Handy for sampled logging, etc."
|
||||||
[probability & body]
|
[probability & body]
|
||||||
|
|
Loading…
Reference in New Issue