[New-bugs-announce] [issue44489] _handle_existing_loggers should respect loggers that were manually disabled

Ron Serruya report at bugs.python.org
Tue Jun 22 08:57:06 EDT 2021


New submission from Ron Serruya <ronserruya at gmail.com>:

The method `_handle_existing_loggers` in the logging lib (called when configuring loggers using dictConfig) iterates over all existing loggers and sets their .disabled attribute according to the `disable_existing_loggers` parameter (usually set to false)

However this only lets the user completely disable/enable all existing loggers, and there is no way to tell the function to keep the value to what it was

This example was how I found about it

1. Imported the pkg ddtrace, which writes some logs that I'm not interested in

2. Disabled the ddtrace logger 
`logging.getLogger('ddtrace.internal.writer').disabled = True`

3. Imported the pkg Sanic, which configures its logging using `logging.configure.dictConfig()`, with `disable_existing_loggers` set to False, as it doesn't want to disable all of the loggers that were created before it

4. `_handle_existing_loggers` re-enabled the logger that I manually disabled before



Ps. apologies if this is not the correct place, I don't really see this as a bug, more like a feature request, however the only place I found for feature requests were PEPs, which this obviously isnt

----------
components: Library (Lib)
messages: 396327
nosy: ronserruya2
priority: normal
severity: normal
status: open
title: _handle_existing_loggers should respect loggers that were manually disabled
versions: Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44489>
_______________________________________


More information about the New-bugs-announce mailing list