Programatically setting log level based on name of logger #8925
Unanswered
wimax-grapl
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi folks! Got a caplog question.
I have some personal code, which calls stuff like
urllib3
,requests
, etc.My personal code specifies multiple
logging.getLogger(...)
with different names, e.g.logging.getLogger("coolproject.module_one")
logging.getLogger("coolproject.module_two.submodule")
stuff like that, you get the gist.
When I specify
pytest --log-level=DEBUG
, obviously that triggers debug statements from not justcoolproject
, but alsourllib3
andrequests
.Would there be a way for me to specify something like:
coolproject
in its name, log level = DEBUG?
I see that caplog supports stuff like
caplog.set_level(logging.CRITICAL, logger="root.baz")
, but that's a concrete logger name.What I'd like is a
caplog.set_level(logging.DEBUG, logger_name_regex="coolproject.*")
Beta Was this translation helpful? Give feedback.
All reactions