From 085dd24a62df7f08608fea096dcfe198079f4c72 Mon Sep 17 00:00:00 2001 From: Joel Bradshaw Date: Sun, 9 Jan 2022 23:26:27 -0800 Subject: [PATCH] Simplify and explain our overrides This should also fix the 500s-in-prod issue, yay --- bookwyrm/settings.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/bookwyrm/settings.py b/bookwyrm/settings.py index 31ad75d8f..a3b0d48d6 100644 --- a/bookwyrm/settings.py +++ b/bookwyrm/settings.py @@ -106,27 +106,30 @@ TEMPLATES = [ }, ] +LOG_LEVEL = env('LOG_LEVEL', 'INFO').upper() +# Override aspects of the default handler to our taste +# See https://docs.djangoproject.com/en/3.2/topics/logging/#default-logging-configuration +# for a reference to the defaults we're overriding LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'handlers': { + # Overrides the default handler, which does not log in prod 'console': { + 'level': LOG_LEVEL, 'class': 'logging.StreamHandler', }, }, - 'root': { - 'handlers': ['console'], - 'level': 'WARNING', - }, 'loggers': { + # Override the log level for the default logger 'django': { - 'handlers': ['console'], - 'level': os.getenv('DJANGO_LOG_LEVEL', 'INFO'), - 'propagate': False, + 'handlers': ['console', 'mail_admins'], + 'level': LOG_LEVEL, }, + # Add a bookwyrm-specific logger 'bookwyrm': { 'handlers': ['console'], - 'level': os.getenv('LOG_LEVEL', 'DEBUG' if DEBUG else 'INFO').upper(), + 'level': LOG_LEVEL, } }, }