Skip to main content

Send logging messages to different channels (only Telegram for now)

Project description

logram

Python logger with different handlers

pip install logram

Add LOGGING configurations

Only different part is telegram handler

import logging
from logging.config import dictConfig
from logram.handlers import Telegram


Telegram.token = "20**:AA*****"
Telegram.chat_id = "-6***"

LOGGING = {
    "version": 1,
    "disable_existing_loggers": False,
    "formatters": {
        "verbose": {
            "format": "[%(levelname)s] [%(asctime)s] [%(module)s] [line:%(lineno)d] %(message)s"
        },
        "simple": {"format": "%(levelname)s %(message)s"},
    },
    "handlers": {
        "file": {
            "level": "INFO",
            "class": "logging.FileHandler",
            "filename": "logs/log",
            "formatter": "verbose",
            "encoding": "UTF-8",
        },
        "console": {
            "level": "INFO",
            "class": "logging.StreamHandler",
            "formatter": "verbose",
        },
        "telegram": {
            "level": "WARNING",
            "class": "logram.handlers.Telegram",
            "formatter": "verbose",
        },
    },
    "loggers": {
        "django": {"handlers": ["console"], "level": "INFO", "propagate": True},
        "offices": {"handlers": ["console", "file"], "level": "INFO", "propagate": False},
        "smsreport": {"handlers": ["console", "telegram",  "file"], "level": "INFO", "propagate": True},
        "qinspect": {"handlers": ["console"], "level": "INFO", "propagate": True,},
    },
}

dictConfig(LOGGING)

Then this will send messages right into the Telegram Group

logging.warning("Send directly to the Telegram group")

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

logram-0.0.3.tar.gz (14.5 kB view details)

Uploaded Source

Built Distribution

logram-0.0.3-py3-none-any.whl (14.7 kB view details)

Uploaded Python 3

File details

Details for the file logram-0.0.3.tar.gz.

File metadata

  • Download URL: logram-0.0.3.tar.gz
  • Upload date:
  • Size: 14.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for logram-0.0.3.tar.gz
Algorithm Hash digest
SHA256 1e6b2c3e9356920577caf1b0c57bf79f27506707340c313df066e852273719a4
MD5 3e38f9b6f017f3dffcd34e532dfbaed0
BLAKE2b-256 a938b187bd4aeee915521ea00ca56fdb5873142f19ad9920b5afcc6fe92bd146

See more details on using hashes here.

File details

Details for the file logram-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: logram-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 14.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for logram-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7c51de3fe0636b8f205f9dd26c0b423e11ed2d3e28ecd20a9f5ea0242fdb38a2
MD5 7c8f7ae228b68ef178c89067feea79db
BLAKE2b-256 350af4c1cefa115c420c0f290117e812aedff748ba3bb7ab959af49ffddd7089

See more details on using hashes here.

Supported by

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