a simple logger that sends 500 exceptions to a Telegram bot of your choice.
Project description
This is a simple logger that sends 500 exceptions to a Telegram bot of your choice.
Quick start
Install django-log-to-telegram:
pip install -e 'git+https://github.com/thela/django_log_to_telegram.git#egg=django_log_to_telegram'
1. register a bot on Telegram (with BotFather), start a chat with it and put the Api token in settings.py:
LOG_TO_TELEGRAM_BOT_TOKEN = '12345678:replace-me-with-real-token'
Different errors will be fired if the BOT_TOKEN is not active or if there is no chat active with it.
add the ‘django_log_to_telegram’ to your INSTALLED_APPS setting:
INSTALLED_APPS = [
...
'django_log_to_telegram',
...
]
add the django_log_to_telegram.log.AdminTelegramHandler to your app’s logging configuration, for example:
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'handlers': {
'telegram_log': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django_log_to_telegram.log.AdminTelegramHandler',
'bot_token': LOG_TO_TELEGRAM_BOT_TOKEN,
}
},
'loggers': {
'django.request': {
'handlers': ['telegram_log'],
'level': 'ERROR',
'propagate': True,
},
},
}
if you want to test this logger in a debug environment, just remove the filters’: [‘require_debug_false’], line in the ‘handlers’ dictionary.
Run python manage.py migrate to create the django_log_to_telegram models.
If everything went well, you bot will then begin sendind messages on 500 exceptions.
There is a very basic test app provided in the folder test_app. It is configured to send errors to telegram even with DEBUG active, so that it can be useful with just a
./manage.py runserver
It does not provide any database configuration, and most of Django basic settings are stripped out, so any use of it outside the very basic testing of the django_log_to_telegram mechanism is deprecated to say the least.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django-log-to-telegram-2019.10.30.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8e19941481f0f088f99d4c6cae3f70460df651ca7f176e0a1c68aba0094e02a0 |
|
MD5 | ed04c15f6f83b3988d8cde5a8acb6db9 |
|
BLAKE2b-256 | 8ad17b50c3f1fc75931e86baf41a085b793126c737a38387effefa6b5f8ef601 |
Hashes for django_log_to_telegram-2019.10.30-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 375cb453f395d2f1d03c16bbfa97dbde00892747dd48fc18828f8ed45236ce2a |
|
MD5 | da576122ed58a08266a46b38e9b07606 |
|
BLAKE2b-256 | e7da73304b124f52af9a0c2d5531434e4e9e542731752fa612b357dd7c337c98 |