Skip to content

Commit

Permalink
[mod] Change default top-level *config* :min-level from :report -> …
Browse files Browse the repository at this point in the history
…:trace

A question from a user just highlighted that the current default level behaviour
is unintuitive.

If `*config*` doesn't have any `:min-level` (rare!), 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 so rare
for anyone to have a `*config*` without an explicit `:min-level`.
  • Loading branch information
ptaoussanis committed Feb 26, 2024
1 parent f3ce2b5 commit 6b165c6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/taoensso/timbre.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,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_
Expand Down
6 changes: 3 additions & 3 deletions test/taoensso/timbre_tests.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,16 @@

(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")

(is (not (:error-level? (log-data "ns" :info {:min-level :info} {} []))))
(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 >= *")
Expand Down

0 comments on commit 6b165c6

Please sign in to comment.