Skip to main content

pfly - Python LOggling Linter

Project description

plly - Python LOggling Linter

A Python logging linter that enforces best practices

Why?

Production incidents are harder to debug when:

  • Exception logs lack stack traces (exc_info=True)
  • Hot loops spam logs, degrading performance
  • Inconsistent logging causes time delay in parsing logs
  • Complementary: Use with structlog, loguru — not instead of them

Installation

uv pip install plly

Usage

plly path/to/code

plly path/to/code --config=plly.yml

Policies

Code Policy Description
LY001 exception_exc_info Enforces exc_info=True in exception handlers to capture stack traces
LY002 log_loop Prevents unconditional logging in hot loops (allows conditional logging)

Configuration

Create a plly.yml:

logger_names: [logger, logging, log]

exception_exc_info:
  levels: [error]
  severity: fail

log_loop:
  levels: [info, debug]
  severity: fail

Examples

LY001: Missing exc_info=True

# Fail
try:
    connect_db()
except Exception:
    logger.error("Connection failed")  # No stack trace!

# Pass
try:
    connect_db()
except Exception:
    logger.error("Connection failed", exc_info=True)

LY002: Logging in hot loops

# Fail
for user in users:
    logger.info(f"Processing {user}")  # Logs every iteration

# Pass
for i, user in enumerate(users):
    if i % 100 == 0:
        logger.info(f"Progress: {i}/{len(users)}")  # Conditional logging

License

Apache

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pfly-0.1.0.tar.gz (1.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pfly-0.1.0-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

Details for the file pfly-0.1.0.tar.gz.

File metadata

  • Download URL: pfly-0.1.0.tar.gz
  • Upload date:
  • Size: 1.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.22

File hashes

Hashes for pfly-0.1.0.tar.gz
Algorithm Hash digest
SHA256 03feb3f8cbd0820c52a7a8529b95997a10f4d723baa527f82736f4f821d72b3e
MD5 b6bcd90dda79c2a70a0272bce1f1df68
BLAKE2b-256 66684b4eacc58127b6670f85f7702ac240579b2633b3f80357f7baccbc4e0c2f

See more details on using hashes here.

File details

Details for the file pfly-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pfly-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.22

File hashes

Hashes for pfly-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7d7d164b6597090d5540f4262050189229d3dd0a5dde1b17970198afa114e0df
MD5 dfa18d6d0cdb9361c43ae0144ef477ac
BLAKE2b-256 c81feadd10167b846eb0b15c265222786f2a3337500346e689ae111ad4128d92

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page