Skip to main content

telegram-logging

Simple Telegram logging with zero dependencies!

https://pypi.org/project/telegram-logging/

Usage:

➡️ See a full example in examples/usage.py

🤖 How to create a Telegram bot

Install:

pip install telegram-logging

Import:

from telegram_logging import TelegramHandler, TelegramFormatter

Create a Formatter and a Handler:

formatter = TelegramFormatter(
    fmt="[%(asctime)s %(name)s] %(levelname)8s\n\n%(message)s",
    datefmt="%d/%m/%Y %H:%M:%S",
    use_emoji=True)

handler = TelegramHandler(
    token="<Your bot token>",
    chat_id="<Your chat id>")

handler.setFormatter(formatter)

*You can get a list of all available handler params here

Use it:

import logging

logger = logging.getLogger(__name__)
logger.addHandler(handler)
logger.setLevel(logging.DEBUG)


logger.info("Hi, here is some information")

Default Emojis:

Emoji Level
⚪️ DEBUG
🔵 INFO
🟠 WARNING
🔴 ERROR
🔥 CRITICAL

You can use your own set of emojis:

telegram

formatter = TelegramFormatter(
    format="[%(asctime)s %(name)s] %(levelname)8s\n\n%(message)s",
    datefmt="%d/%m/%Y %H:%M:%S",
    use_emoji=True,
    emoji_map={
        logging.DEBUG: "🐛",
        logging.INFO: "💡",
        logging.ERROR: "🚨",
    })

Release files for telegram-logging 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for telegram-logging 1.0.0
File Size Uploaded
telegram_logging-1.0.0.tar.gz 3.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for telegram-logging 1.0.0
File Interpreter ABI Platform
telegram_logging-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 7.5 kB

Release files / telegram_logging-1.0.0.tar.gz

Download URL telegram_logging-1.0.0.tar.gz
Size 3.5 kB
Tags Source
SHA-256 checksum
How to use checksums
7677ee492b2de55e45d85de4edab6686b34ce51898a95c5022c9e5b2bc843a3b
BLAKE2b-256 checksum
How to use checksums
eb6e47014eae86f124d18d5fe80600ada09f36ea9897a053fce0b0ba487b6b6a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release files / telegram_logging-1.0.0-py3-none-any.whl

Download URL telegram_logging-1.0.0-py3-none-any.whl
Size 4.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
38ccd6a94602e874d32ff7d395d0bed258a2bfa8f51d4d605ecc87b837acb764
BLAKE2b-256 checksum
How to use checksums
160e2d18bf6b5bf5afd8a5ef1cd0d7eb7119a1f8cefd1dcedcf8055e464e73aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.161

2 release files

0.16

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