Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi, I use
click_log
for an application with many logger instances, each of which outputs a lot of debug information. To make debugging a single component easier, I implemented a custom decorator@verbosity_option
that makes it possible to silence parts of the application.Is this a feature that would be useful to have in
click_log
? Naming is up for debate and documentation can surely be improved. Also I'm not quite sure what the minimum python version is that should be supported (I usedf
-strings and maybe some other "new" features in there).Below is the commit message for this pull request:
This decorator is intended for complex applications which have multiple nested logger instances. It can be used to selectivly toggle log levels for loggers and their child loggers. A use case for this would be when one has a large application that has a detailed debug output across its modules. When debugging a single module, one wants to silence debug output of all modules except for this one.
Imagine an application with multiple logger instance such as this:
The verbosity options provided by this decorator take a comma-separated list of
<LOGGER>=<LEVEL>
assignments (which set levels for child loggers of theapp_logger
) or<LEVEL>
statements (which set the verbosity ofapp_logger
itself). Runningthen prints
Notice how the output of
bar_logger
was supressed, as python loggers inherit their log level from their parent loggers; in this caseapp_logger
.This decorator is a drop-in replacement for
@simple_verbosity_option
; supplying-v <LEVEL>
does exactly the same for both decorators.