Skip to main content

xlogging

A lightweight extension on top of Python's built-in logging module. Structured, readable output for local dev and production services.

What it solves

stdlib logging emits flat, hard-to-read text. When a log record carries nested context — request metadata, exception details, tags — there's no clean way to display or store it. xlogging adds structured formatters and a first-class LogEvent record so that context travels with the message.

Key features

  • TreeFormat / ColorTreeFormat — renders nested dicts and lists as a Unicode tree, readable in terminal
  • JsonFormat — emits newline-delimited JSON for file storage and log aggregators
  • EventStream — a Logger subclass that accepts metadata and tags per call, and supports per-logger timezone
  • LogEvent — a LogRecord subclass with created_at, metadata, and tags fields
  • FileGroup — rotating file handler that defaults to JSON format
  • ConsoleGroup — stream handler with pluggable formatter

Usage

from xlogging import EventStream, ColorTreeFormat, ConsoleGroup

stream = EventStream.from_options(
    name="app",
    handlers=[ConsoleGroup(format=ColorTreeFormat())],
)

stream.info(
    "order filled",
    metadata={"symbol": "AAPL", "qty": 100, "price": 189.5},
    tags={"strategy": "momentum"},
)

stream.error(
    "execution failed",
    metadata={"order_id": "x-001", "reason": "insufficient margin"},
)

Terminal output:

[2026-08-31 09:00:00][INFO]: order filled
    ├── metadata:
    │   ├── symbol: AAPL
    │   ├── qty: 100
    │   └── price: 189.5
    └── tags:
        └── strategy: momentum

File handler

from xlogging import EventStream, FileGroup

stream = EventStream.from_options(
    name="app",
    handlers=[FileGroup(path="logs/", name="app")],
)

Writes rotating JSON logs to logs/app.log (10 MB per file, 1 backup by default).

Install

pip install lib-x-xlogging

Requires Python 3.11+. Runtime dependency: colorlog.

Metadata

Release files for lib-x-xlogging 1.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lib-x-xlogging 1.6.0
File Size Uploaded Provenance Actions
lib_x_xlogging-1.6.0.tar.gz 20.0 kB Without provenance Details for lib_x_xlogging-1.6.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for lib-x-xlogging 1.6.0
File Interpreter ABI Platform Actions
lib_x_xlogging-1.6.0-py3-none-any.whl Python 3 none any Details for lib_x_xlogging-1.6.0-py3-none-any.whl

Total release size: 49.9 kB

Release files / lib_x_xlogging-1.6.0.tar.gz

Download URL lib_x_xlogging-1.6.0.tar.gz
Size 20.0 kB
Tags Source
SHA-256 checksum
How to use checksums
9461adf62db52fde2f10cbf704d916d82175644119d8a8dc9db98d7f97d6aedb
BLAKE2b-256 checksum
How to use checksums
21d2cdc295b08171894532d2c3e51cbc97cc78e9affaa14b903e9a93b1184b4b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.16

Release files / lib_x_xlogging-1.6.0-py3-none-any.whl

Download URL lib_x_xlogging-1.6.0-py3-none-any.whl
Size 29.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4f54ba164bdcc2bf54afb71690b72101242776714db060603472d7346305e08d
BLAKE2b-256 checksum
How to use checksums
51e601a8aa2b8803e00d851c0e45a9c775635bcd266b5280e8c5dfdcabb1f45b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.16

Security for lib-x-xlogging 1.6.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page