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

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.2
File Size Uploaded Provenance Actions
lib_x_xlogging-1.6.2.tar.gz 20.2 kB Without provenance Details for lib_x_xlogging-1.6.2.tar.gz

Built distribution (wheel)

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

Total release size: 50.2 kB

Release files / lib_x_xlogging-1.6.2.tar.gz

Download URL lib_x_xlogging-1.6.2.tar.gz
Size 20.2 kB
Tags Source
SHA-256 checksum
How to use checksums
8689ac3588b763fda6a50382c12554c205145c67cd323d219550e074e9dd6db8
BLAKE2b-256 checksum
How to use checksums
3cfb393a147d65bb5cff313563dec132a4a077e6b87d73b51b0459c4203f9c4f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.16

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

Download URL lib_x_xlogging-1.6.2-py3-none-any.whl
Size 30.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a8cc9c33f8ae61e21b776d6c01120d5cf2d2b0b47f8e372eaaff02bb6c6d00fb
BLAKE2b-256 checksum
How to use checksums
ec1661112fcb00af2e2bbb102c0dac4d1cafda70f3babeb11914e01d03cf55f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.16

Security for lib-x-xlogging 1.6.2

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