Skip to content

Commit a393582

Browse files
committed
[mod] Throw on invalid compile-time min-level
This is technically a breaking change. Before this commit: If an invalid compile-time min-level was provided, it would be silently ignored. User would need to specifically check their *config* :compile-time-config value to see that something went wrong. After this commit: If an invalid compile-time min-level is provided, immediately throw. This'd happen at compile-time. Motivation: The previous behaviour made it easy to miss an invalid compile-time min-level. While the change introduced here is technically breaking, it would break ONLY those users with an invalid min-level - and it'd break them only at compile-time. So this should hopefully be a welcome change if documented clearly.
1 parent 49c5de4 commit a393582

1 file changed

Lines changed: 8 additions & 13 deletions

File tree

src/taoensso/timbre.cljc

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -168,19 +168,14 @@
168168
])
169169

170170
level (if (string? level) (keyword level) level) ; Legacy
171-
present? (some? level)
172-
valid? (valid-level? level)]
173-
174-
(swap! compile-time-config_ assoc :min-level
175-
(when present?
176-
(if valid?
177-
level
178-
[:timbre/invalid-min-level
179-
{:value level :type (type level)}])))
180-
181-
(when valid?
182-
;; (println (str "Compile-time (elision) Timbre min-level: " level))
183-
level))))
171+
]
172+
173+
(when (some? level)
174+
(if-not (valid-level? level)
175+
(throw (ex-info (str "Invalid compile-time min-level: " level) {:level (enc/typed-val level)}))
176+
(do
177+
(swap! compile-time-config_ assoc :min-level level)
178+
level))))))
184179

185180
#?(:clj
186181
(defonce ^:private compile-time-ns-filter

0 commit comments

Comments
 (0)