Skip to main content

A production-grade Django logging handler that ships log records to a Telegram supergroup.

Project description

django-tgwarden

PyPI Python Django License: MIT

A production-grade Django logging handler that ships log records to a Telegram supergroup with per-severity topic routing, batching, deduplication, rate-limiting, and a non-blocking async worker.

Features:

  • 🚀 Non-blocking — daemon thread + asyncio, never slows your app
  • 📋 Per-level topic routing — DEBUG/INFO/WARNING/ERROR/CRITICAL each in their own forum topic
  • 🔒 PII scrubbing — passwords, tokens, credit cards redacted before reaching Telegram

Installation

pip install django-tgwarden

Quick start

# settings.py
INSTALLED_APPS = [..., "tgwarden"]

TGWARDEN = {
    "BOT_TOKEN": "your-bot-token",
    "CHAT_ID": "-100your-supergroup-id",
    "TOPICS": {
        "DEBUG": 5, "INFO": 6, "WARNING": 7, "ERROR": 8, "CRITICAL": 9,
    },
}

LOGGING = {
    "version": 1,
    "handlers": {
        "telegram": {"class": "tgwarden.handlers.TelegramHandler", "level": "WARNING"},
    },
    "root": {"handlers": ["telegram"], "level": "WARNING"},
}

Then verify:

python manage.py tgwarden_test --message "Hello from tgwarden!"

Development

git clone https://github.com/joma-research-and-development-group/django-tgwarden.git
cd django-tgwarden
python -m venv .venv && source .venv/bin/activate
pip install -e .[dev]
pytest

License

MIT

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

django_tgwarden-0.1.1.tar.gz (60.0 kB view details)

Uploaded Source

Built Distribution

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

django_tgwarden-0.1.1-py3-none-any.whl (24.5 kB view details)

Uploaded Python 3

File details

Details for the file django_tgwarden-0.1.1.tar.gz.

File metadata

  • Download URL: django_tgwarden-0.1.1.tar.gz
  • Upload date:
  • Size: 60.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for django_tgwarden-0.1.1.tar.gz
Algorithm Hash digest
SHA256 86bbe1a3f6ea6dad24b497ddcf55696da2a387554eaf4a063fcf1b925b590927
MD5 1e1a0f4718d3d17f37d5ad2f9027e6fd
BLAKE2b-256 57b273278980fdc4cf6e98791ac38779552ffed451d1cfd2a4085e2e01d9f3b8

See more details on using hashes here.

File details

Details for the file django_tgwarden-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for django_tgwarden-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 97e9c3c5c4e0df894fcf564e18090762dc4817e7c25d931e87edac924dd33cb0
MD5 1d4944b9a71032dcc3ab4790c9bc0fb1
BLAKE2b-256 dc021b0ec8a30c25e4679f376daf26704114299185110c90ba7094415af0b655

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