Skip to main content

Zero-config PII redaction for Python logging

Project description

HushLog

Zero-config PII redaction for Python logging.

PyPI version Python versions CI License: MIT

Features

  • Zero-config — one call to hushlog.patch() and you're done
  • Non-invasive — wraps existing formatters, no logger rewrites needed
  • Performant — pre-compiled regex with heuristic early-exit checks
  • Type-safe — fully typed with PEP 561 py.typed marker
  • Python 3.10+ — supports Python 3.10 through 3.13

Installation

pip install hushlog

Or with uv:

uv add hushlog

Quick Start

import logging
import hushlog

hushlog.patch()

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

logger.info("User email: john@example.com")
# Output: User email: [EMAIL REDACTED]

logger.info("Card: 4111-1111-1111-1111")
# Output: Card: [CREDIT_CARD REDACTED]

What Gets Redacted

Pattern Example Input Redacted Output
Email john@example.com [EMAIL REDACTED]
Credit Card 4111-1111-1111-1111 [CREDIT_CARD REDACTED]
SSN 123-45-6789 [SSN REDACTED]
Phone (555) 123-4567 [PHONE REDACTED]

Credit card detection includes Luhn checksum validation to minimize false positives.

Planned Patterns (v0.2.0+)

IPv4/IPv6 addresses, AWS keys, Stripe keys, GitHub tokens, JWT tokens, and more. See the roadmap for details.

Configuration

Disable specific patterns or add custom ones:

from hushlog import Config

hushlog.patch(Config(
    disable_patterns=frozenset({"phone"}),
    custom_patterns={"internal_id": r"ID-[A-Z]{3}-[0-9]{6}"},
))

Contributing

Contributions are welcome! See CONTRIBUTING.md for guidelines.

License

MIT -- see LICENSE for details.

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

hushlog-0.1.0a3.tar.gz (57.5 kB view details)

Uploaded Source

Built Distribution

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

hushlog-0.1.0a3-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file hushlog-0.1.0a3.tar.gz.

File metadata

  • Download URL: hushlog-0.1.0a3.tar.gz
  • Upload date:
  • Size: 57.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for hushlog-0.1.0a3.tar.gz
Algorithm Hash digest
SHA256 35feb7338dedc4496afde43cb489500154812de7c17ef9e216172542ea767eae
MD5 8093114e4ea1143ee9529e61172e8c60
BLAKE2b-256 8da4a307859b748dd8ca4e6b67e09ecaa91903935440ee7bdcd533d898e208ca

See more details on using hashes here.

Provenance

The following attestation bundles were made for hushlog-0.1.0a3.tar.gz:

Publisher: release.yml on FelipeMorandini/hushlog

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hushlog-0.1.0a3-py3-none-any.whl.

File metadata

  • Download URL: hushlog-0.1.0a3-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for hushlog-0.1.0a3-py3-none-any.whl
Algorithm Hash digest
SHA256 544917dedbcc3da67943b050d39a56c64b616b02599e97c5ab56da3361c9af89
MD5 fb8532dd045711c49ca293617d0e61ad
BLAKE2b-256 d13ec9f9ad81f463cfda65f6d04d51805cc53ade1dec037716e7ee34e9fe6d29

See more details on using hashes here.

Provenance

The following attestation bundles were made for hushlog-0.1.0a3-py3-none-any.whl:

Publisher: release.yml on FelipeMorandini/hushlog

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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