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.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_id': LOG_TO_TELEGRAM_BOT_TOKEN,
}
},
'loggers': {
'django.request': {
'handlers': ['telegram_log'],
'level': 'ERROR',
'propagate': True,
},
},
}
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.4b0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f3a531ebdbbee53c21e6f1da19fa6f84fa2bc07615ce1c845ac14fdca414abb |
|
MD5 | cd8f39ab066fcc7b2a8ae36e5865656e |
|
BLAKE2b-256 | 68bbc498095cafcd9ef2f75929527190d63840c04b11f4b018c8af013dc58308 |
Hashes for django_log_to_telegram-2019.4b0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e234e85366a212460933b3b978b05dd610f12a1a4b43086af189f7d8e4680dad |
|
MD5 | ffbe6acaeecfa62184c6a6cd88901e92 |
|
BLAKE2b-256 | 576fa22c29293820db7979748b3047711a50c8ba38fd0b106d8e45ea4579439d |