From e05601db229a281273c66503467b7ed84d98f7d3 Mon Sep 17 00:00:00 2001 From: Jason McBrayer Date: Tue, 5 Jun 2018 08:18:06 -0400 Subject: [PATCH] Add extra debug logging to production --- brutaldon/settings.py | 52 +++++++++++++++++++++++++++++++++++++++++++ brutaldon/views.py | 4 ---- 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/brutaldon/settings.py b/brutaldon/settings.py index ad3d69f..42f9d52 100644 --- a/brutaldon/settings.py +++ b/brutaldon/settings.py @@ -103,6 +103,58 @@ AUTH_PASSWORD_VALIDATORS = [ }, ] +LOGGING = { + 'version': 1, + 'disable_existing_loggers': False, + 'filters': { + 'require_debug_false': { + '()': 'django.utils.log.RequireDebugFalse', + }, + 'require_debug_true': { + '()': 'django.utils.log.RequireDebugTrue', + }, + }, + 'formatters': { + 'django.server': { + '()': 'django.utils.log.ServerFormatter', + 'format': '[%(server_time)s] %(message)s', + } + }, + 'handlers': { + 'console': { + 'level': 'INFO', + 'filters': ['require_debug_true'], + 'class': 'logging.StreamHandler', + }, + 'console_debug_false': { + 'level': 'ERROR', + 'filters': ['require_debug_false'], + 'class': 'logging.StreamHandler', + }, + 'django.server': { + 'level': 'INFO', + 'class': 'logging.StreamHandler', + 'formatter': 'django.server', + }, + 'mail_admins': { + 'level': 'ERROR', + 'filters': ['require_debug_false'], + 'class': 'django.utils.log.AdminEmailHandler' + } + }, + 'loggers': { + 'django': { + 'handlers': ['console', 'console_debug_false', 'mail_admins'], + 'level': 'INFO', + }, + 'django.server': { + 'handlers': ['django.server'], + 'level': 'INFO', + 'propagate': False, + } + } +} + # Internationalization # https://docs.djangoproject.com/en/2.0/topics/i18n/ diff --git a/brutaldon/views.py b/brutaldon/views.py index b100cc7..58ecbb3 100644 --- a/brutaldon/views.py +++ b/brutaldon/views.py @@ -35,7 +35,6 @@ def get_mastodon(request): raise NotLoggedInException() if request.session['access_token'] in pool.keys(): mastodon = pool[request.session['access_token']] - print("Mastodon from pool") else: mastodon = Mastodon( client_id = client.client_id, @@ -43,7 +42,6 @@ def get_mastodon(request): api_base_url = client.api_base_id, access_token = request.session['access_token'], ratelimit_method='throw') - print("New Mastodon added to pool") pool[request.session['access_token']] = mastodon else: try: @@ -54,7 +52,6 @@ def get_mastodon(request): raise NotLoggedInException() if user.access_token in pool.keys(): mastodon = pool[user.access_token] - print("Mastodon from pool") else: mastodon = Mastodon( client_id = client.client_id, @@ -63,7 +60,6 @@ def get_mastodon(request): api_base_url = client.api_base_id, ratelimit_method="throw") print("New Mastodon added to pool") - pool[user.access_token] = mastodon return mastodon def fullbrutalism_p(request):