Skip to main content

Simple Telegram logging with zero dependencies.

Project description

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: "🚨",
    })

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

telegram_logging-1.0.0.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

telegram_logging-1.0.0-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file telegram_logging-1.0.0.tar.gz.

File metadata

  • Download URL: telegram_logging-1.0.0.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for telegram_logging-1.0.0.tar.gz
Algorithm Hash digest
SHA256 7677ee492b2de55e45d85de4edab6686b34ce51898a95c5022c9e5b2bc843a3b
MD5 95aa20380efd6501f7bebc369755675d
BLAKE2b-256 eb6e47014eae86f124d18d5fe80600ada09f36ea9897a053fce0b0ba487b6b6a

See more details on using hashes here.

File details

Details for the file telegram_logging-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: telegram_logging-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for telegram_logging-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 38ccd6a94602e874d32ff7d395d0bed258a2bfa8f51d4d605ecc87b837acb764
MD5 80d62d4be31247776f8f48b511027361
BLAKE2b-256 160e2d18bf6b5bf5afd8a5ef1cd0d7eb7119a1f8cefd1dcedcf8055e464e73aa

See more details on using hashes here.

Supported by

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