Back

set-ns-min-level (clj)

(source)

function

(set-ns-min-level config ?min-level) (set-ns-min-level config ns ?min-level)
Returns given Timbre `config` with its `:min-level` modified so that the given namespace has the specified minimum logging level. When no namespace is provided, `*ns*` will be used. When `?min-level` is nil, any minimum level specifications for the *exact* given namespace will be removed. See `*config*` docstring for more about `:min-level`. See also `set-min-level!` for a util to directly modify `*config*`.

Examples

timbre
(ns taoensso.timbre-tests
  (:require
   [clojure.test    :as test :refer [deftest testing is]]
   [taoensso.encore :as enc]
   [taoensso.timbre :as timbre])

(deftest _set-ns-min-level
  [(is (= (timbre/set-ns-min-level {:min-level :info         } "a" :trace) {:min-level [["a" :trace] ["*" :info]]}))
   (is (= (timbre/set-ns-min-level {:min-level [["a" :debug]]} "a" :trace) {:min-level [["a" :trace]]}))
   (is (= (timbre/set-ns-min-level {:min-level [["a" :debug]]} "a" nil)    {:min-level nil}))

   (is (= (timbre/set-ns-min-level {:min-level [["a.b" :trace] ["a.c" :debug] ["a.*" :info] ["a.c" :error]]}
            "a.c" :report)
         {:min-level [["a.c" :report] ["a.b" :trace] ["a.*" :info]]}))

   (is (= (->
            (timbre/set-ns-min-level {:min-level :info} "foo" :debug)
            (timbre/set-ns-min-level "foo" nil))
         {:min-level :info}))])