Let all fields be configurable

Previously only merged in pre-defined configuration keys. Now all fields
from client's config is merged into the timbre config.

Improved state handling by reseting config state when running init!.
Signed-off-by: Snorre Magnus Davøen's avatarSnorre Magnus Davøen <snorre.davoen@nsd.no>
parent f9e439ef
(defproject no.nsd/envelope "0.1.2"
(defproject no.nsd/envelope "0.1.3"
:description "A thin wrapper around taoensso.timbre with built in settings for logging to NSD's ELK stack"
:url "https://gitlab.nsd.no/clojure/envelope"
:license {:name "Eclipse Public License"
......
......@@ -62,16 +62,17 @@
[conf]
(let [current-conf (swap! envelope-config merge conf)
elk? (:log-to-elk current-conf)]
(timbre/merge-config! {:timestamp-opts (if elk?
{:pattern "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"}
{:pattern (:console-time-pattern current-conf)
:timezone :jvm-default})
:level (or (:level current-conf)
(if elk? :info :debug))
:output-fn (if elk?
(partial nsd-logstash-format-fn current-conf)
(or (:output-fn current-conf)
local-console-format-fn))})
(timbre/merge-config! (merge current-conf
{:timestamp-opts (if elk?
{:pattern "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"}
{:pattern (:console-time-pattern current-conf)
:timezone :jvm-default})
:level (or (:level current-conf)
(if elk? :info :debug))
:output-fn (if elk?
(partial nsd-logstash-format-fn current-conf)
(or (:output-fn current-conf)
local-console-format-fn))}))
current-conf))
......@@ -80,6 +81,7 @@
([] (init! {}))
([conf]
#?(:clj (cljlog/use-timbre))
(reset! envelope-config default-config)
(merge-config! (merge default-config conf))
(timbre/debug "Logging envelope initialized")))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment