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.1.tar.gz
(14.4 kB
view details)
Built Distribution
logram-0.0.1-py3-none-any.whl
(14.7 kB
view details)
File details
Details for the file logram-0.0.1.tar.gz
.
File metadata
- Download URL: logram-0.0.1.tar.gz
- Upload date:
- Size: 14.4 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | f60e5671f620405dcf38fb2ba369c48e841a1e221f9dc0c7a74ae9f070e22388 |
|
MD5 | 48be342e453a1151adf2dd9f8e19503b |
|
BLAKE2b-256 | 012b45ed1ecd519524ac2c2fab102c27463917eb477f08ad603398924f3395dc |
File details
Details for the file logram-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: logram-0.0.1-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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 34f521587a3eef72a246a300bcdfff3f65720a1c4b434091a5fa07ebb20229e5 |
|
MD5 | dd4eb8c238f1062489cc04606effdea0 |
|
BLAKE2b-256 | f90883fd3a170329f52d64540e81856f75027da382909b8bce803c8a94c894ce |