Skip to main content

Stdlib-only structured logging — rotation, JSON, context, redaction.

Project description

codechu-log

PyPI Python License: MIT

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 with RotatingFileHandler and a TTY-aware console handler.
  • Context(**fields) — context manager backed by contextvars; nested scopes merge, child wins on key conflict, propagation survives await.
  • 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

License

MIT — see LICENSE.

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

codechu_log-0.1.0.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

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

codechu_log-0.1.0-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

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

Hashes for codechu_log-0.1.0.tar.gz
Algorithm Hash digest
SHA256 da4bd848df1e2ef45ff171b8bb04565dfd23df94b852a934810af62289cd409d
MD5 0fd2b59ed9e96306c2582df920e329cb
BLAKE2b-256 4321c024b2164ddba24efbc944a4dcb55252f9c581cc82c4754bd327ff47cd21

See more details on using hashes here.

Provenance

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

Publisher: release.yml on codechu/log-py

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

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

Hashes for codechu_log-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 616d3c25b0dd9d99ec8be94f7815d655927abd191cdf9cf09f6e9e9f39ec7e2a
MD5 5901c6108e4e13e973ec11923550e785
BLAKE2b-256 ecc9ae1cac86fd0499a72edce5aed3aaa7a58dd9620e0cdebfd7a29d7ae1595e

See more details on using hashes here.

Provenance

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

Publisher: release.yml on codechu/log-py

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