Python · architecture
no-stdlib-logging
python:no-stdlib-logging Application code imports standard-library logging instead of the configured house logger.
- Code
- SARJ052
- Default
- error
- Fix
- none
- Languages
- python
Why
Parallel logger hierarchies can bypass shared formatting, redaction, levels, sinks, and error reporting.
Fix
Import the configured loguru logger; keep stdlib logging only in the explicit bridge module.
Before / after
Executed by this rule’s unit tests.
Before
Application imports stdlib logging
import logging
logger = logging.getLogger(__name__)
After
Application imports loguru
from loguru import logger
Limits
- Tests, scripts, notebooks, generated files, type-only imports, and recognized loguru bridge configuration are excluded.
- Detection reports imports of the standard-library logging root, not similarly named first-party modules.