Skip to main content

Taggin

Welcome

Taggin is a tiny layer on top of the Python stdlib logger that treats attribute access as dynamic tags (log.TRAIN.BATCH("...")). Tags can be filtered via glob patterns, assigned custom log levels, rate limited, and every log is mirrored into a structured store that can be searched or exported.

Installation

Install via pip (or pixi/uv) with:

pip install taggin

The CLI depends on arrow and cyclopts (included), colorful console output uses rich, and saving/reading Parquet requires pandas plus a backend such as pyarrow or fastparquet.

Usage

Quick start

from datetime import datetime
from taggin import (
    setup_logger,
    get_log_storage,
    set_visible_tags,
    set_tag_style,
)

log = setup_logger(enable_color=True)  # enables Rich-powered colors where supported
set_visible_tags(["TRAIN.*", "io.net"])
set_tag_style("TRAIN.START", color="green", emoji="🚂")

log.info("Booting")
log.TRAIN.START("epoch=%s", 1)
log.io.net("connected to redis")

storage = get_log_storage()
storage.save_text("logs/run.txt")                # new file
storage.save_text("logs/run.txt", append=True)   # append to existing file
storage.save_parquet("logs/run.parquet")         # requires pandas + pyarrow

recent = storage.search_by_date(start=datetime.utcnow().replace(hour=0, minute=0))
by_tag = storage.search_by_tag("TRAIN.*")
approx = storage.search_fuzzy("redis connection failed", threshold=0.5)

When enable_color=True, tags render in color (and can add emoji via set_tag_style). Disable the flag to fall back to plain text.

All structured entries store the timestamp, level, logger name, tag, and message so they remain queryable even if the original message contains its own time or date. This makes ad-hoc debugging easy whether you prefer grepping the text artifact or using a DataFrame/Parquet workflow.

CLI search utility

A small cyclopts-powered CLI is available for exploring saved logs without writing Python. Assuming you saved either a structured text log or Parquet file:

taggin by-tag logs/run.txt "TRAIN.*"
taggin by-date logs/run.parquet --start "2025-01-01" --end "2025-01-05"
taggin fuzzy logs/run.txt "redis timeout" --threshold 0.4 --limit 5
taggin tags logs/run.txt                    # list all known tags
taggin by-tag logs/run.txt "TRAIN.*" --json-output   # machine-friendly

Each command prints matching entries in the same concise [TAG] message style, or JSON (when --json-output is provided) for downstream scripting.

Tests

Run the small pytest suite (which also exercises the Parquet writer when pandas is available) with:

pytest

Documentation

This repo ships MkDocs docs (Home, Examples, API Reference). Preview locally:

mkdocs serve

or build static files via mkdocs build. The content lives under docs/.

Release files for taggin 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 taggin 0.1.2
File Size Uploaded
taggin-0.1.2.tar.gz 39.4 kB Details

Built distribution (wheel)

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

Total release size: 51.5 kB

Release files / taggin-0.1.2.tar.gz

Download URL taggin-0.1.2.tar.gz
Size 39.4 kB
Tags Source
SHA-256 checksum
How to use checksums
f4fe0fa5e3cc6fd031b450a49ac5578ef59ba878c307ef6e39271d0748c7f398
BLAKE2b-256 checksum
How to use checksums
f1a59ad93440325d55e4c4e7b86adf04a8b8f5bd7f68bf79569a6468353edb92
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

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

Download URL taggin-0.1.2-py3-none-any.whl
Size 12.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4cf9cd98d9cd8acc3d26b9e159b81c607b5675af49b26e8e6d744e1ec8e87b33
BLAKE2b-256 checksum
How to use checksums
6b6cfdc52dc6827dc2258d27489f45680f5397286061eed0678e5c41c9bf87d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

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