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.2.tar.gz
(14.5 kB
view details)
Built Distribution
logram-0.0.2-py3-none-any.whl
(14.1 kB
view details)
File details
Details for the file logram-0.0.2.tar.gz
.
File metadata
- Download URL: logram-0.0.2.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7069a4662c5653b7eb722160739a8f9708b232bd21020ef2ff803c3dbd51f3b0 |
|
MD5 | b81a9430005bddde98ec95bbe025762b |
|
BLAKE2b-256 | caa2f7d77bba10fbd02c6442e51be913d41f6fc1d7aaec35582e2ae1f849c1a7 |
File details
Details for the file logram-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: logram-0.0.2-py3-none-any.whl
- Upload date:
- Size: 14.1 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 | 3ddc6e378098584f696f3fc3e28752d3205b4b8aaae93fab883b63838c221461 |
|
MD5 | 969330a3ce33e08be5c63e4c155c20d6 |
|
BLAKE2b-256 | 506c6bdf86f18ec2bd77092ed6f65865cba8b59999425407797ae2c056d582c4 |