Skip to main content

python-traceprint

Readable print and logging output with timestamps, elapsed time, labels, nesting depth and optional terminal colors. Requires Python 3.12 or later and has no runtime dependencies. The API is alpha.

The distribution is named python-traceprint; Python code imports traceprint. Importing it does not replace process streams. Install a tracer explicitly when you want to format ordinary print() calls.

Installation

From a local checkout:

python -m pip install .

Install the public distribution from PyPI:

python -m pip install python-traceprint

The first public release is 0.1.2; the API remains alpha.

Documentation · PyPI

Quick start

from traceprint import Tracer

tracer = Tracer(use_colors=False, use_tabulation=True)
tracer.install()
try:
    with tracer.span("load"):
        print("loaded", 42, "records")
finally:
    tracer.uninstall()

Each nonblank line gets one prefix, even when print() writes several arguments. Partial writes appear immediately. Nesting adds labels and, when enabled, indentation. Timestamps use UTC; elapsed times use a monotonic performance clock.

To avoid replacing sys.stdout, pass a tracer directly to print():

from traceprint import Tracer, trace

tracer = Tracer()


@trace(tracer_instance=tracer, label="work")
def work() -> None:
    print("doing the thing", file=tracer)


work()

Python logging can use the same formatting:

import logging

from traceprint import Tracer, TracerHandler

tracer = Tracer()
handler = TracerHandler(tracer_instance=tracer)
logger = logging.getLogger("example")
logger.addHandler(handler)
logger.setLevel(logging.INFO)
logger.propagate = False
logger.info("ready")
logger.removeHandler(handler)
handler.close()

Tracer labels and stream installation are shared mutable state. Use this library for scripts and development output; it does not provide isolated thread or async task contexts or distributed tracing.

Documentation and examples

Build the searchable HTML documentation locally:

uv sync --dev
uv run sphinx-build -W --keep-going -b html docs docs/_build/html

Open docs/_build/html/index.html in a browser, or use the published documentation site.

Development

uv sync --dev
uv run macrostates check
uv run macrostates change-check
uv run pytest
uv run ruff check .
uv run ruff format --check .
uv run pyright
uv build

The canonical repository is LLL-Devs/python-traceprint. Specifications and implementation records live under .macrostates/. The development environment pins Macrostates CLI 0.5.0. The distribution version has its own authority in .macrostates/implementation/deliverables.yaml, independent of the initial specs-1.0.0 and imp-1.0.0 repository baselines. See the release policy.

The local GitHub Actions workflow checks tests across Python 3.12–3.15 on Linux and Python 3.12 on Windows and macOS, plus lint, types, documentation and package builds. Documentation is built and deployed by the GitHub Pages workflow.

License

MIT, copyright © 2026 Lucas Lopez. Vendored Macrostates specifications retain their upstream licenses.

Metadata

Release files for python-traceprint 0.1.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 python-traceprint 0.1.2
File Size Uploaded
python_traceprint-0.1.2.tar.gz 106.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for python-traceprint 0.1.2
File Interpreter ABI Platform
python_traceprint-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 115.5 kB

Release files / python_traceprint-0.1.2.tar.gz

Download URL python_traceprint-0.1.2.tar.gz
Size 106.0 kB
Tags Source
SHA-256 checksum
How to use checksums
ce2ac610dfd0260acc640f01bf0fb8fea1681e3be4ac1c15adeb6624b64286bb
BLAKE2b-256 checksum
How to use checksums
19e7fc2628f4e9699227972c3063157af6ed2711e18891b3a2c413e349e414bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 14, 2026.

Transparency log

Release files / python_traceprint-0.1.2-py3-none-any.whl

Download URL python_traceprint-0.1.2-py3-none-any.whl
Size 9.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
198feb6372e2035407f683a5ffeddf353e003c4e49237236b54fdeab934d85c8
BLAKE2b-256 checksum
How to use checksums
771a654046d7b5b0b283bf69ef43e6eda655e38fca62544957f8977cb1612959
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 14, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

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