Skip to content

PY-LOGG0001 · logger_boundary_bypass_count

Count direct logger provider calls outside the configured project boundary.

This is a deterministic rule for python. Read its implementation.

Resolve absolute imports through module, class, function, and lambda scopes. Count calls to a configured logger constructor, module-level logging function, or direct logger object when the calling module does not define preferred_logger. The house default is common.log.logger. Calls through that project-owned logger remain valid. This rule does not inspect print, which remains Ruff T201 ownership.

Each finding records the exact resolved provider, preferred qualified logger, and source call. Assignments and parameters that shadow an imported name make resolution uncertain and suppress the finding. The result is the number of proven bypass calls. The value is the number of proven bypass calls.

The module that defines the preferred logger may construct its underlying provider. Logging types used only in annotations, handler configuration, external adapters, unresolved calls, and relative imports receive no finding. Projects without the house logger can configure a different qualified symbol or disable this policy. direct_logger_symbols names the providers a call may reach, covering the standard library, loguru, and structlog by default, so a project using another logging library adds it.

import logging
logger = logging.getLogger(__name__)
logging.warning("retrying")
from common.log import logger
logger.warning("retrying")
  • Cites “Python HOWTOs”, Configuring Logging for a Library. Open reference
  • Cites “Python HOWTOs”, Using logging in multiple modules. Open reference
  • Cites “Loguru documentation”, Migration from standard logging. Open reference