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.7.1

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.7.1
File Size Uploaded Provenance Actions
lib_x_xlogging-1.7.1.tar.gz 20.4 kB Without provenance Details for lib_x_xlogging-1.7.1.tar.gz

Built distribution (wheel)

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

Total release size: 50.7 kB

Release files / lib_x_xlogging-1.7.1.tar.gz

Download URL lib_x_xlogging-1.7.1.tar.gz
Size 20.4 kB
Tags Source
SHA-256 checksum
How to use checksums
e2153fac4134cebc95c8a448c1c1099e4dc14b89ad8ff7c87d2b1e69e219d2aa
BLAKE2b-256 checksum
How to use checksums
d07e7c5eeedf05bd98d211156faeeaed80fc76e7f840dab9d6ad98b900c9d193
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.7.1-py3-none-any.whl

Download URL lib_x_xlogging-1.7.1-py3-none-any.whl
Size 30.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1e2395951287459cb6cb4814b2982295b0a6dd8040ebe07fc09c7f8412ae97e5
BLAKE2b-256 checksum
How to use checksums
de6a8980dad1053fd2c4973ccf6651edf0bba43dcf15567de1c4cabf9346379a
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.7.1

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