From 2a9c20361efbbeaf8b9d8838ec96fdfb8d68acd9 Mon Sep 17 00:00:00 2001 From: Peter Taoussanis Date: Mon, 18 Dec 2023 10:09:05 +0100 Subject: [PATCH] [mod] Change default top-level `*config*` :min-level from :report -> :trace A question from a user just highlighted that the current default level behaviour is unintuitive. If `*config*` doesn't have any `:min-level`, that should imply that no minimum level exists (i.e. any level should be fine). But instead the current behaviour is flipped (no `:min-level` restricts all but `:report` level logs). Note that the appender's `:min-level` already defaults to the (intuitively sensible) `:trace`, so the current behaviour is not only surprising but also inconsistent. This is a BREAKING CHANGE but should hopefully affect few folks since it's unlikely anyone would be relying on the undocumented default. --- src/taoensso/timbre.cljc | 2 +- test/taoensso/timbre_tests.cljc | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/taoensso/timbre.cljc b/src/taoensso/timbre.cljc index 0996dc17..98236c71 100644 --- a/src/taoensso/timbre.cljc +++ b/src/taoensso/timbre.cljc @@ -637,7 +637,7 @@ ([config level ?ns-str ?file ?line msg-type ?err vargs_ ?base-data callsite-id spying?] (-log! config level ?ns-str ?file ?line nil msg-type ?err vargs_ ?base-data callsite-id spying?)) ([config level ?ns-str ?file ?line ?column msg-type ?err vargs_ ?base-data callsite-id spying?] - (when (may-log? :report level ?ns-str config) + (when (may-log? :trace level ?ns-str config) (let [instant (enc/now-dt*) context *context* vargs @vargs_ diff --git a/test/taoensso/timbre_tests.cljc b/test/taoensso/timbre_tests.cljc index 6a7459af..636d6c77 100644 --- a/test/taoensso/timbre_tests.cljc +++ b/test/taoensso/timbre_tests.cljc @@ -60,7 +60,8 @@ (deftest levels [(testing "Levels.global/basic" - [(is (map? (log-data "ns" :trace {:min-level :trace} {} [])) "call >= min") + [(is (map? (log-data "ns" :trace {:min-level nil} {} [])) "call >= default (:trace)") + (is (map? (log-data "ns" :trace {:min-level :trace} {} [])) "call >= min") (is (nil? (log-data "ns" :trace {:min-level :info} {} [])) "call < min") (is (map? (log-data "ns" :info {:min-level :info} {} [])) "call >= min") @@ -68,8 +69,7 @@ (is (boolean (:error-level? (log-data "ns" :error {:min-level :error} {} []))))]) (testing "Levels.global/by-ns" - [(is (nil? (log-data "ns.2" :info {:min-level [["ns.1" :info] ]} {} [])) "call < default") - (is (map? (log-data "ns.2" :report {:min-level [["ns.1" :info] ]} {} [])) "call >= default") + [(is (map? (log-data "ns.2" :trace {:min-level [["ns.1" :info] ]} {} [])) "call >= default (:trace)") (is (map? (log-data "ns.2" :info {:min-level [["ns.1" :warn] ["ns.2" :info]]} {} [])) "call >= match") (is (map? (log-data "ns.2" :info {:min-level [["ns.1" :warn] [#{"ns.3" "ns.2"} :info]]} {} [])) "call >= match") (is (map? (log-data "ns.2" :info {:min-level [["ns.1" :warn] ["*" :info]]} {} [])) "call >= *")