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.0.tar.gz (59.2 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.0-py3-none-any.whl (24.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django_tgwarden-0.1.0.tar.gz
  • Upload date:
  • Size: 59.2 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.0.tar.gz
Algorithm Hash digest
SHA256 8b0a6fa83e3446ef2ade5e19ebc10d69a69f6a087bf0ee4152a2a90fdbd11713
MD5 e72cd2b012670b2ff6f6186838a2340d
BLAKE2b-256 2b274d4930ede99ca08446c3cda3d36a63ddb0a31ab4a38c5a90a5f3d334a8b8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_tgwarden-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2da5e4118830dcc4e2b5c0d3c2b68b65bd0225e0d79324e191b3e6c184972cd0
MD5 3804887a2d9d55ccb3eca0169ada9a48
BLAKE2b-256 0a7a69527212cd35e781dfcb516b70a37500d211d22e3ab8698f9ec834bb48c8

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