Closed pjlegato closed 1 year ago
@pjlegato Hi Paul!
You are correct that there's currently no built-in util for this. And agree that it might be nice to have one, good idea π
I'd recommend the following API:
(set-ns-min-level [config ?min-level] [config ns ?min-level]) ; Returns an updated config map
(set-ns-min-level! [?min-level] [ns ?min-level] [ns ?min-level]) ; Uses `alter-var-root` with `set-ns-min-level` and `*config*`.
Where
nil
?min-level
=> remove any specific entryns
defaults to *ns*
.Am happy to implement this myself next time I'm working on Timbre (I expect that getting the implementation right might be somewhat non-trivial). Also happy to look at a PR if you'd like to submit one.
The above-mentioned utils will be added in a forthcoming release π
Adjust the log level for just one specific namespace seems to be non-trivial (unless I've missed a builtin function somehow): I currently have a single code block like:
where I can toggle either
dev.jt.iboga.plumbing
orfoo.bar
between:info
and:debug
by commenting and uncommenting, then re-evaluating the statement.The disadvantages of this approach are that it requires centralized logging level specification -- that is, log levels are usually not specified in the file of the namespace they affect, and it's quite verbose.
Is there any interest in a function like:
which would live locally within each source file, and auto-adjust the log level for the namespace it's being loaded into?
As I understand it, such a function would have to:
:min-level
;