Closed antonmos closed 3 years ago
Hey @antonmos, I have a few recommendations for this (with various levels of granularity).
My personal recommendation is to try and scope it as tightly as possible -- just incase you're throwing away logs that might be important.
Here are my suggestions in order of preference:
(def test-log-settings {:level :warn ..})
(deftest my-test-that-uses-a-noisy-library
(timbre/with-merged-config timbre-test-settings
(is (= ..)))
(defn with-timbre-config [config]
(fn [f]
(timbre/with-merged-config config
(f))))
(t/use-fixtures :once (with-timbre-config {:level :debug}))
(t/deftest test-output
(timbre/info "info level")
(timbre/warn "warn level"))
(ns test-injections
(:require [taoensso.timbre :as timbre]))
(timbre/merge-config! {:level :warn})
And in your project.clj file, add/modify your test profile to "inject" test-injections
namespace.
(defproject ...
:profiles {
:test {:injections [(require 'test-injections)]}
}
)
i havent thought using injections for this! i think that's what i was looking for. Thank you!
@rymndhng Thanks Raymond!
i think this might be similar to what the original question was in https://github.com/ptaoussanis/timbre/issues/9 but it is closed.
So, i need to call
timbre/merge-config
from somewhere so that i dont get excessive debug logging from various java libs.For
lein repl
, I can useand call
timbre/merge-config
from therepl
ns.But how do i do it for
lein test
? Thanks!