Skip to content

Commit

Permalink
🔊(prod) move logging config up to Base configuration class
Browse files Browse the repository at this point in the history
This move makes it possible to set logging configuration on a per-deployment
basis in production.
  • Loading branch information
Laurent Bossavit authored and Laurent Bossavit committed Feb 12, 2025
1 parent fbb4797 commit 09114a3
Showing 1 changed file with 36 additions and 35 deletions.
71 changes: 36 additions & 35 deletions src/backend/people/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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="

Expand Down

0 comments on commit 09114a3

Please sign in to comment.