flake8-logging-format
What it is and what it does
This is a flake8 plugin that enforces a specific logging discipline: it detects when Python logging calls use format strings, concatenation, f-strings, or other string-building techniques instead of passing non-constant data through the logging `extra` dictionary. The plugin checks for violations like `.format()`, `%` formatting, `+` concatenation, and f-strings in log messages, and can optionally enforce that `extra` keys come from a whitelisted set to prevent accidental exposure of sensitive data in logs.
The package is designed for teams that want to separate log message templates (constants) from dynamic data (passed via `extra`), reducing the risk of sensitive information leaking into logs through careless string construction. It supports plugin-based whitelisting via entry points and has special handling for debug-level logs and debug-prefixed keys. No runtime dependencies are required; it integrates directly into flake8's linting workflow.
Use it for:
- Enforce consistent logging patterns across a codebase to prevent accidental data leakage in production logs.
- Validate that logging calls use the `extra` dictionary instead of string formatting for dynamic values.
- Whitelist allowed field names in logging `extra` dictionaries to catch typos or unauthorized keys.
- Detect and flag improper exception logging (e.g., using `error(..., exc_info=True)` instead of `exception()`).
- Prevent use of deprecated `warn()` method in favor of the standard `warning()` method.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A flake8 extension that enforces logging best practices by detecting and preventing format strings, concatenation, and other anti-patterns in Python logging calls.
Yes. This is a lightweight, actively maintained flake8 extension with no dependencies, permissive licensing, and a clear, focused purpose. Install it if your team wants to enforce structured logging discipline and reduce the risk of sensitive data leaking through log statements. The violation codes are disabled by default, so you can adopt it incrementally by enabling only the rules that match your logging policy.
Install
flake8-logging-format on PyPI
pip
pip install flake8-logging-formatuv
uv add flake8-logging-formatpoetry
poetry add flake8-logging-formatInstalling flake8-logging-format
Before you install
Low friction installation as a pure Python wheel with no runtime dependencies. Actively maintained with recent releases; last commit in 2026-04-12 and latest release in 2024-06-11.
License in practice
Licensed under Apache License 2.0 (permissive), allowing free use, modification, and distribution with minimal restrictions.
Quickstart
pip install flake8-logging-format
# In setup.cfg or .flake8:
[flake8]
enable-extensions=G
# Then run:
flake8 your_code.py
Verify before relying
- Whether the package requires a specific minimum Python version (requires_python is unspecified in metadata)
- Whether all violation codes (G001–G202) are enabled by default or require explicit configuration beyond enable-extensions=G
Package facts
| License | Apache License 2.0 (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 794 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 368,055/month — #7,191 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: flake8_logging_format-2024.24.12-py3-none-any.whl
Keywords: microcosm
Tags
More Quality Assurance packages
Coverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
ruffRuff is a Python linter and code formatter…
permissive · top 1,000 on PyPI
pexpectPexpect spawns and controls interactive console…
permissive · top 1,000 on PyPI
blackBlack reformats Python source code to a…
permissive · top 1,000 on PyPI
pytest-xdistpytest-xdist distributes pytest tests across…
permissive · top 1,000 on PyPI
cfn-lintValidates AWS CloudFormation templates in YAML…
permissive · top 1,000 on PyPI
flake8-loggingA Flake8 plugin that detects and flags common…
permissive · top 15,000 on PyPI
flake8-implicit-str-concatA Flake8 plugin that detects and reports…
permissive · top 15,000 on PyPI
flake8-no-implicit-concatA flake8 plugin that detects and forbids…
permissive · top 15,000 on PyPI
flake8-pieA flake8 plugin that detects code quality…
permissive · top 15,000 on PyPI
flake8-copyrightA flake8 plugin that enforces the presence of…
unclear · top 15,000 on PyPI
flake8-literalA flake8 plugin that enforces consistent…
copyleft · top 15,000 on PyPI
flake8-noqaA flake8 plugin that validates the formatting…
copyleft · top 5,000 on PyPI
flake8-printA flake8 plugin that detects print statements…
permissive · top 5,000 on PyPI
logging-formatter-anticrlfA drop-in replacement for Python's standard…
permissive · top 15,000 on PyPI
mypy-strict-kwargsA mypy plugin that enforces…
permissive · top 15,000 on PyPI