MCPcopy Create free account
hub / github.com/pytest-dev/pytest / configure_logging

Function configure_logging

doc/en/conf.py:401–421  ·  view source on GitHub ↗

Configure Sphinx's WarningHandler to handle (expected) missing include.

(app: "sphinx.application.Sphinx")

Source from the content-addressed store, hash-verified

399
400
401def configure_logging(app: "sphinx.application.Sphinx") -> None:
402 """Configure Sphinx's WarningHandler to handle (expected) missing include."""
403 import sphinx.util.logging
404 import logging
405
406 class WarnLogFilter(logging.Filter):
407 def filter(self, record: logging.LogRecord) -> bool:
408 """Ignore warnings about missing include with "only" directive.
409
410 Ref: https://github.com/sphinx-doc/sphinx/issues/2150."""
411 if (
412 record.msg.startswith('Problems with "include" directive path:')
413 and "_changelog_towncrier_draft.rst" in record.msg
414 ):
415 return False
416 return True
417
418 logger = logging.getLogger(sphinx.util.logging.NAMESPACE)
419 warn_handler = [x for x in logger.handlers if x.level == logging.WARNING]
420 assert len(warn_handler) == 1, warn_handler
421 warn_handler[0].filters.insert(0, WarnLogFilter())
422
423
424def setup(app: "sphinx.application.Sphinx") -> None:

Callers 1

setupFunction · 0.85

Calls 2

WarnLogFilterClass · 0.85
insertMethod · 0.80

Tested by

no test coverage detected