mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-23 16:40:36 +00:00
Add the required bits for Django's logger
So, you can't define handlers piecewise, and if you redefine a logger, you have to also include everything it uses, because your "new" logger doesn't have a reference to the original logging config to get things like mail_admins and require_debug_false. require_debug_true isn't strictly necessary here, but it seemed strange to just copy over one of them.
This commit is contained in:
parent
13a2c58b98
commit
27acf668df
1 changed files with 26 additions and 2 deletions
|
@ -110,18 +110,42 @@ 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
|
||||
#
|
||||
# It seems that in order to override anything you have to include its
|
||||
# entire dependency tree (handlers and filters) which makes this a
|
||||
# bit verbose
|
||||
LOGGING = {
|
||||
"version": 1,
|
||||
"disable_existing_loggers": False,
|
||||
"filters": {
|
||||
# These are copied from the default configuration, required for
|
||||
# implementing mail_admins below
|
||||
"require_debug_false": {
|
||||
"()": "django.utils.log.RequireDebugFalse",
|
||||
},
|
||||
"require_debug_true": {
|
||||
"()": "django.utils.log.RequireDebugTrue",
|
||||
},
|
||||
},
|
||||
"handlers": {
|
||||
# Overrides the default handler, which does not log in prod
|
||||
# Overrides the default handler to make it log to console
|
||||
# regardless of the DEBUG setting (default is to not log to
|
||||
# console if DEBUG=False)
|
||||
"console": {
|
||||
"level": LOG_LEVEL,
|
||||
"class": "logging.StreamHandler",
|
||||
},
|
||||
# This is copied as-is from the default logger, and is
|
||||
# required for the django section below
|
||||
"mail_admins": {
|
||||
"level": "ERROR",
|
||||
"filters": ["require_debug_false"],
|
||||
"class": "django.utils.log.AdminEmailHandler",
|
||||
},
|
||||
},
|
||||
"loggers": {
|
||||
# Override the log level for the default logger
|
||||
# Install our new console handler for Django's logger, and
|
||||
# override the log level while we're at it
|
||||
"django": {
|
||||
"handlers": ["console", "mail_admins"],
|
||||
"level": LOG_LEVEL,
|
||||
|
|
Loading…
Reference in a new issue