Stdlib-only structured logging — rotation, JSON, context, redaction.
Project description
codechu-log
Stdlib-only structured logging for Python 3.10+. One call configures a
rotating file handler, a TTY-aware console handler, optional JSON output,
and a redaction list. Context is propagated through contextvars so it
works across await boundaries.
from codechu_log import setup, bind, Context
log = bind(setup("myapp", file="app.log", json=True), service="api")
with Context(request_id="r-42"):
log.info("started", user="onur")
Output (one JSON object per line):
{"ts": "2026-05-20T12:34:56.789012+00:00", "level": "INFO",
"logger": "myapp", "msg": "started",
"fields": {"service": "api", "request_id": "r-42", "user": "onur"},
"exc_info": null, "pid": 4321, "thread": "MainThread"}
Features
setup(name, *, level, file, json, max_bytes, backup_count, fmt, redact)— one-call configuration withRotatingFileHandlerand a TTY-aware console handler.Context(**fields)— context manager backed bycontextvars; nested scopes merge, child wins on key conflict, propagation survivesawait.bind(logger, **fields)— always-on fields per logger.structured(logger)—log.info("msg", key=value)lifts kwargs into the structured payload.redact=[...]— replace listed field keys with<redacted>in both text and JSON output.
Install
pip install codechu-log
Documentation
- API reference — every public symbol and the JSON schema.
- Recipes — common configurations.
- CHANGELOG
License
MIT — see LICENSE.
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 codechu_log-0.1.0.tar.gz.
File metadata
- Download URL: codechu_log-0.1.0.tar.gz
- Upload date:
- Size: 10.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da4bd848df1e2ef45ff171b8bb04565dfd23df94b852a934810af62289cd409d
|
|
| MD5 |
0fd2b59ed9e96306c2582df920e329cb
|
|
| BLAKE2b-256 |
4321c024b2164ddba24efbc944a4dcb55252f9c581cc82c4754bd327ff47cd21
|
Provenance
The following attestation bundles were made for codechu_log-0.1.0.tar.gz:
Publisher:
release.yml on codechu/log-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codechu_log-0.1.0.tar.gz -
Subject digest:
da4bd848df1e2ef45ff171b8bb04565dfd23df94b852a934810af62289cd409d - Sigstore transparency entry: 1582341427
- Sigstore integration time:
-
Permalink:
codechu/log-py@29b5386d3c769bc87ee7737a3b199be97857e418 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/codechu
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@29b5386d3c769bc87ee7737a3b199be97857e418 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file codechu_log-0.1.0-py3-none-any.whl.
File metadata
- Download URL: codechu_log-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
616d3c25b0dd9d99ec8be94f7815d655927abd191cdf9cf09f6e9e9f39ec7e2a
|
|
| MD5 |
5901c6108e4e13e973ec11923550e785
|
|
| BLAKE2b-256 |
ecc9ae1cac86fd0499a72edce5aed3aaa7a58dd9620e0cdebfd7a29d7ae1595e
|
Provenance
The following attestation bundles were made for codechu_log-0.1.0-py3-none-any.whl:
Publisher:
release.yml on codechu/log-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codechu_log-0.1.0-py3-none-any.whl -
Subject digest:
616d3c25b0dd9d99ec8be94f7815d655927abd191cdf9cf09f6e9e9f39ec7e2a - Sigstore transparency entry: 1582341650
- Sigstore integration time:
-
Permalink:
codechu/log-py@29b5386d3c769bc87ee7737a3b199be97857e418 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/codechu
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@29b5386d3c769bc87ee7737a3b199be97857e418 -
Trigger Event:
workflow_dispatch
-
Statement type: