From d08198e44d2738ebabf912e158877da629a0f684 Mon Sep 17 00:00:00 2001 From: Laurent Bossavit Date: Wed, 12 Feb 2025 14:30:23 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=8A(prod)=20move=20logging=20config=20?= =?UTF-8?q?up=20to=20Base=20configuration=20class?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This move makes it possible to set logging configuration on a per-deployment basis in production. --- src/backend/people/settings.py | 71 +++++++++++++++++----------------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/src/backend/people/settings.py b/src/backend/people/settings.py index 3fc8537..4d3a25c 100755 --- a/src/backend/people/settings.py +++ b/src/backend/people/settings.py @@ -323,6 +323,42 @@ class Base(Configuration): SESSION_CACHE_ALIAS = "default" SESSION_COOKIE_AGE = 60 * 60 * 12 # 12 hours to match Agent Connect + # Python loggers configuration (and env var overrides) + LOGGING = { + "version": 1, + "disable_existing_loggers": False, + "formatters": { + "simple": { + "format": "{asctime} {name} {levelname} {message}", + "style": "{", + }, + }, + "handlers": { + "console": { + "class": "logging.StreamHandler", + "formatter": "simple", + }, + }, + # Override root logger to send it to console + "root": { + "handlers": ["console"], + "level": values.Value( + "INFO", environ_name="LOGGING_LEVEL_LOGGERS_ROOT", environ_prefix=None + ), + }, + "loggers": { + "core": { + "handlers": ["console"], + "level": values.Value( + "INFO", + environ_name="LOGGING_LEVEL_LOGGERS_APP", + environ_prefix=None, + ), + "propagate": False, + }, + }, + } + # OIDC - Authorization Code Flow OIDC_CREATE_USER = values.BooleanValue( default=True, @@ -617,41 +653,6 @@ class Development(Base): USE_SWAGGER = True - LOGGING = { - "version": 1, - "disable_existing_loggers": False, - "formatters": { - "simple": { - "format": "{asctime} {name} {levelname} {message}", - "style": "{", - }, - }, - "handlers": { - "console": { - "class": "logging.StreamHandler", - "formatter": "simple", - }, - }, - # Override root logger to send it to console - "root": { - "handlers": ["console"], - "level": values.Value( - "INFO", environ_name="LOGGING_LEVEL_LOGGERS_ROOT", environ_prefix=None - ), - }, - "loggers": { - "core": { - "handlers": ["console"], - "level": values.Value( - "INFO", - environ_name="LOGGING_LEVEL_LOGGERS_APP", - environ_prefix=None, - ), - "propagate": False, - }, - }, - } - # this is a dev credentials for mail provisioning API MAIL_PROVISIONING_API_CREDENTIALS = "bGFfcmVnaWU6cGFzc3dvcmQ="