Skip to main content

Taggin logging with dynamic tags, structured storage, and CLI search.

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

taggin-0.1.0.tar.gz (39.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

taggin-0.1.0-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

Details for the file taggin-0.1.0.tar.gz.

File metadata

  • Download URL: taggin-0.1.0.tar.gz
  • Upload date:
  • Size: 39.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for taggin-0.1.0.tar.gz
Algorithm Hash digest
SHA256 57dbf228f0a0eda8d9ed80d032dbf4f029e0f106f84648947d374cb7c18246e1
MD5 382680b24746ed0b3845480ee1b88f81
BLAKE2b-256 2a2ee30a3b815af45eaff7ddf7bba74c62435117ae11d1f04da99fbf891ea87b

See more details on using hashes here.

File details

Details for the file taggin-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: taggin-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for taggin-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5ce2f0e6821243ec6375a5fb70af4df753622ad7b49d52de815bf7a87753840e
MD5 f3d487fee5205be87b2dd2a10369e482
BLAKE2b-256 ecdc5b2fd065ac5f06f3f6f51fd7a52a0ddbe60657d472c6c57600c28a9b9f95

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page