Zero-config PII redaction for Python logging
Project description
HushLog
Zero-config PII redaction for Python logging.
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.typedmarker - 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 |
|---|---|---|
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35feb7338dedc4496afde43cb489500154812de7c17ef9e216172542ea767eae
|
|
| MD5 |
8093114e4ea1143ee9529e61172e8c60
|
|
| BLAKE2b-256 |
8da4a307859b748dd8ca4e6b67e09ecaa91903935440ee7bdcd533d898e208ca
|
Provenance
The following attestation bundles were made for hushlog-0.1.0a3.tar.gz:
Publisher:
release.yml on FelipeMorandini/hushlog
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hushlog-0.1.0a3.tar.gz -
Subject digest:
35feb7338dedc4496afde43cb489500154812de7c17ef9e216172542ea767eae - Sigstore transparency entry: 1134288024
- Sigstore integration time:
-
Permalink:
FelipeMorandini/hushlog@9e1b4c8bd13874bef61dbfba7b69ce3a6c488294 -
Branch / Tag:
refs/tags/v0.1.0a3 - Owner: https://github.com/FelipeMorandini
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@9e1b4c8bd13874bef61dbfba7b69ce3a6c488294 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
544917dedbcc3da67943b050d39a56c64b616b02599e97c5ab56da3361c9af89
|
|
| MD5 |
fb8532dd045711c49ca293617d0e61ad
|
|
| BLAKE2b-256 |
d13ec9f9ad81f463cfda65f6d04d51805cc53ade1dec037716e7ee34e9fe6d29
|
Provenance
The following attestation bundles were made for hushlog-0.1.0a3-py3-none-any.whl:
Publisher:
release.yml on FelipeMorandini/hushlog
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hushlog-0.1.0a3-py3-none-any.whl -
Subject digest:
544917dedbcc3da67943b050d39a56c64b616b02599e97c5ab56da3361c9af89 - Sigstore transparency entry: 1134288073
- Sigstore integration time:
-
Permalink:
FelipeMorandini/hushlog@9e1b4c8bd13874bef61dbfba7b69ce3a6c488294 -
Branch / Tag:
refs/tags/v0.1.0a3 - Owner: https://github.com/FelipeMorandini
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@9e1b4c8bd13874bef61dbfba7b69ce3a6c488294 -
Trigger Event:
push
-
Statement type: