From e51ad2eb44fbc04907ed5cd0c9cbf6685a061bc6 Mon Sep 17 00:00:00 2001 From: Kylmakalle Date: Wed, 19 Jun 2019 22:48:45 +0300 Subject: [PATCH] Added sentry error logger --- bot.py | 3 +-- config.py | 7 +++++++ requirements.txt | 2 ++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/bot.py b/bot.py index 23ed7b1..1bb6d32 100644 --- a/bot.py +++ b/bot.py @@ -113,7 +113,6 @@ async def all_errors_handler(dp, update, e): user = update.callback_query.from_user.full_name user_id = update.callback_query.from_user.id - logging.error(f'The update was: {update}') - logging.exception(traceback.print_exc()) + logging.exception(f'The update was: {ujson.dumps(update.to_python(), indent=4)}', exc_info=True) return True diff --git a/config.py b/config.py index 187b296..f7af819 100644 --- a/config.py +++ b/config.py @@ -53,3 +53,10 @@ AUDIO_API_VERSION = os.environ.get('API_VERSION', '5.78') # https://www.miniwebtool.com/django-secret-key-generator/ # Возможно достаточно заглушки в стиле 'tgvkbot-super-secret-key(nope)' SECRET_KEY = os.environ.get('SECRET_KEY', '!jh4wm=%s%l&jv7-lru6hg)mq2pk&rd@i*s0*c!v!zv01cf9iw') + +SENTRY_URL = os.environ.get('SENTRY_URL', None) + +if SENTRY_URL: + import sentry_sdk + + sentry_sdk.init(SENTRY_URL) diff --git a/requirements.txt b/requirements.txt index 7f04d0e..05f7fcf 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,6 +13,8 @@ multidict==4.1.0 Pillow==5.1.0 psycopg2-binary==2.7.4 pytz==2018.3 +sentry-sdk==0.9.0 ujson==1.35 +urllib3==1.25.3 wget==3.2 yarl==1.1.1