MCPcopy Index your code
hub / github.com/python/cpython / _handle_existing_loggers

Function _handle_existing_loggers

Lib/logging/config.py:178–198  ·  view source on GitHub ↗

When (re)configuring logging, handle loggers which were in the previous configuration but are not in the new configuration. There's no point deleting them as other threads may continue to hold references to them; and by disabling them, you stop them doing any logging. However,

(existing, child_loggers, disable_existing)

Source from the content-addressed store, hash-verified

176 return handlers
177
178def _handle_existing_loggers(existing, child_loggers, disable_existing):
179 """
180 When (re)configuring logging, handle loggers which were in the previous
181 configuration but are not in the new configuration. There's no point
182 deleting them as other threads may continue to hold references to them;
183 and by disabling them, you stop them doing any logging.
184
185 However, don't disable children of named loggers, as that's probably not
186 what was intended by the user. Also, allow existing loggers to NOT be
187 disabled if disable_existing is false.
188 """
189 root = logging.root
190 for log in existing:
191 logger = root.manager.loggerDict[log]
192 if log in child_loggers:
193 if not isinstance(logger, logging.PlaceHolder):
194 logger.setLevel(logging.NOTSET)
195 logger.handlers = []
196 logger.propagate = True
197 else:
198 logger.disabled = disable_existing
199
200def _install_loggers(cp, handlers, disable_existing):
201 """Create and install loggers"""

Callers 2

_install_loggersFunction · 0.85
configureMethod · 0.85

Calls 1

setLevelMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…