This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: logging module needs some form of introspection or debugging support
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.8
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: jackjansen, vinay.sajip
Priority: normal Keywords:

Created on 2020-09-03 15:29 by jackjansen, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (3)
msg376308 - (view) Author: Jack Jansen (jackjansen) * (Python committer) Date: 2020-09-03 15:29
The logging module and its API make it easy to modify the behaviour of all loggers used in any package in your program.

Unfortunately the downside of this is that if any author of any module that you use changes the global logger configuration you get in a situation where all your logger calls are not behaving as expected. Moreover, it is very difficult to debug this and to find the culprit.

If the logger module had a global "debug logger usage" flag which would make it emit a log message whenever a call changed the global configuration this would help, especially if the messages were vectored through a single function or method that you could then set a breakpoint on.
msg376311 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2020-09-03 18:57
> if any author of any module that you use changes the global logger configuration

This is an anti-pattern - any library module which does this should have a bug report raised about it. Only applications should change the logging configuration. Can you share which libraries are causing this type of problem for you?

I'm not sure emitting a message using the logging machinery itself would work as expected, as under the changed configuration the dispatch of logging messages might not work as you expect.

Why does setting breakpoints on logging.basicConfig, logging.config.fileConfig and logging.config.dictConfig not work for your use case?
msg376400 - (view) Author: Jack Jansen (jackjansen) * (Python committer) Date: 2020-09-04 20:35
@vinay, absolutely right on this being an anti-pattern:-)

And also right on the statement that I can set a breakpoint on all three of logging.basicConfig, logging.config.fileConfig and logging.config.dictConfig, I had overlooked that (was looking for a single place to put the breakpoint).

I'll close this.
History
Date User Action Args
2022-04-11 14:59:35adminsetgithub: 85870
2020-09-04 20:35:02jackjansensetstatus: open -> closed

messages: + msg376400
stage: resolved
2020-09-03 18:57:30vinay.sajipsetmessages: + msg376311
2020-09-03 15:49:13xtreaksetnosy: + vinay.sajip
2020-09-03 15:29:28jackjansencreate