mirror of
https://github.com/status-im/timbre.git
synced 2025-01-27 12:16:17 +00:00
Added set-config!, set-level! as per suggestion by Jonathan Fischer Friberg
Signed-off-by: Peter Taoussanis <p.taoussanis@gmail.com>
This commit is contained in:
parent
602d527f39
commit
244749a3e2
31
README.md
31
README.md
@ -68,29 +68,29 @@ java.lang.Exception: Oh noes
|
||||
Easily adjust the current logging level:
|
||||
|
||||
```clojure
|
||||
(swap! timbre/config assoc :current-level :warn)
|
||||
(timbre/set-level! :warn)
|
||||
```
|
||||
|
||||
Enable the standard [Postal](https://github.com/drewr/postal)-based email appender:
|
||||
|
||||
```clojure
|
||||
(swap! timbre/config assoc-in [:shared-appender-config :postal]
|
||||
^{:host "mail.isp.net" :user "jsmith" :pass "sekrat!!1"}
|
||||
{:from "me@draines.com" :to "foo@example.com"})
|
||||
(timbre/set-config! [:shared-appender-config :postal]
|
||||
^{:host "mail.isp.net" :user "jsmith" :pass "sekrat!!1"}
|
||||
{:from "me@draines.com" :to "foo@example.com"})
|
||||
|
||||
(swap! timbre/config assoc-in [:appenders :postal :enabled?] true)
|
||||
(timbre/set-config! [:appenders :postal :enabled?] true)
|
||||
```
|
||||
|
||||
Rate-limit to one email per message per minute:
|
||||
|
||||
```clojure
|
||||
(swap! timbre/config assoc-in [:appenders :postal :max-message-per-msecs 60000])
|
||||
(timbre/set-config! [:appenders :postal :max-message-per-msecs 60000])
|
||||
```
|
||||
|
||||
And make sure emails are sent asynchronously:
|
||||
|
||||
```clojure
|
||||
(swap! timbre/config assoc-in [:appenders :postal :async?] true)
|
||||
(timbre/set-config! [:appenders :postal :async?] true)
|
||||
```
|
||||
|
||||
### Custom Appenders
|
||||
@ -98,14 +98,15 @@ And make sure emails are sent asynchronously:
|
||||
Writing a custom appender is easy:
|
||||
|
||||
```clojure
|
||||
(swap! timbre/config assoc-in [:appenders :my-appender]
|
||||
{:doc "Hello-world appender"
|
||||
:min-level :debug
|
||||
:enabled? true
|
||||
:async? false
|
||||
:max-message-per-msecs nil ; No rate limiting
|
||||
:fn (fn [{:keys [message] :as appender-args}]
|
||||
(println "Hello world!" message))})
|
||||
(timbre/set-config!
|
||||
[:appenders :my-appender]
|
||||
{:doc "Hello-world appender"
|
||||
:min-level :debug
|
||||
:enabled? true
|
||||
:async? false
|
||||
:max-message-per-msecs nil ; No rate limiting
|
||||
:fn (fn [{:keys [message] :as appender-args}]
|
||||
(println "Hello world!" message))})
|
||||
```
|
||||
|
||||
See `(doc timbre/config)` for more information on appenders.
|
||||
|
@ -69,6 +69,9 @@
|
||||
;; {:from "me@draines.com" :to "foo@example.com"}
|
||||
:shared-appender-config {:postal nil}}))
|
||||
|
||||
(defn set-config! [ks val] (swap! config assoc-in ks val))
|
||||
(defn set-level! [level] (set-config! [:current-level] level))
|
||||
|
||||
;;;; Define and sort logging levels
|
||||
|
||||
(def ^:private ordered-levels [:trace :debug :info :warn :error :fatal])
|
||||
|
Loading…
x
Reference in New Issue
Block a user