Skip to content

Commit 9f66f73

Browse files
committed
🔧(backend) fix logging for docker and make it configurable by envar
Logs were not made to the console so it was hard to debug in k8s. We propose a ready made logging configuration that sends everything to the console and allow adjusting log levels with environment variables.
1 parent c3da28b commit 9f66f73

File tree

4 files changed

+48
-20
lines changed

4 files changed

+48
-20
lines changed

CHANGELOG.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,23 @@ and this project adheres to
1111

1212
## Added
1313

14+
- 🌐(backend) add german translation #259
1415
- 🌐(frontend) Add German translation #255
1516
- ✨(frontend) Add a broadcast store #387
1617
- ✨(backend) config endpoint #425
1718

18-
1919
## Changed
2020

2121
- 🚸(backend) improve users similarity search and sort results #391
22-
- 🌐(backend) add german translation #259
2322
- ♻️(frontend) simplify stores #402
2423
- ✨(frontend) update $css Box props type to add styled components RuleSet #423
2524

2625
## Fixed
2726

27+
- 🔧(backend) fix logging for docker and make it configurable by envar #427
2828
- 🦺(backend) add comma to sub regex #408
2929
- 🐛(editor) collaborative user tag hidden when read only #385
30-
- 🐛(frontend) user have view access when revoked #387
30+
- 🐛(frontend) users have view access when revoked #387
3131

3232

3333
## [1.7.0] - 2024-10-24

env.d/development/common.dist

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ DJANGO_SECRET_KEY=ThisIsAnExampleKeyForDevPurposeOnly
44
DJANGO_SETTINGS_MODULE=impress.settings
55
DJANGO_SUPERUSER_PASSWORD=admin
66

7+
# Logging
8+
# Set to DEBUG level for dev only
9+
LOGGING_LEVEL_HANDLERS_CONSOLE=INFO
10+
LOGGING_LEVEL_LOGGERS_ROOT=INFO
11+
LOGGING_LEVEL_LOGGERS_APP=INFO
12+
713
# Python
814
PYTHONPATH=/app
915

src/backend/impress/settings.py

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,42 @@ class Base(Configuration):
488488
environ_prefix=None,
489489
)
490490

491+
# Logging
492+
# We want to make it easy to log to console but by default we log production
493+
# to Sentry and don't want to log to console.
494+
LOGGING = {
495+
"version": 1,
496+
"disable_existing_loggers": False,
497+
"handlers": {
498+
"console": {
499+
"class": "logging.StreamHandler",
500+
"level": values.Value(
501+
"ERROR",
502+
environ_name="LOGGING_LEVEL_HANDLERS_CONSOLE",
503+
environ_prefix=None,
504+
),
505+
},
506+
},
507+
# Override root logger to send it to console
508+
"root": {
509+
"handlers": ["console"],
510+
"level": values.Value(
511+
"INFO", environ_name="LOGGING_LEVEL_LOGGERS_ROOT", environ_prefix=None
512+
),
513+
},
514+
"loggers": {
515+
"core": {
516+
"handlers": ["console"],
517+
"level": values.Value(
518+
"INFO",
519+
environ_name="LOGGING_LEVEL_LOGGERS_APP",
520+
environ_prefix=None,
521+
),
522+
"propagate": False,
523+
},
524+
},
525+
}
526+
491527
# pylint: disable=invalid-name
492528
@property
493529
def ENVIRONMENT(self):
@@ -583,23 +619,6 @@ def __init__(self):
583619
class Test(Base):
584620
"""Test environment settings"""
585621

586-
LOGGING = values.DictValue(
587-
{
588-
"version": 1,
589-
"disable_existing_loggers": False,
590-
"handlers": {
591-
"console": {
592-
"class": "logging.StreamHandler",
593-
},
594-
},
595-
"loggers": {
596-
"impress": {
597-
"handlers": ["console"],
598-
"level": "DEBUG",
599-
},
600-
},
601-
}
602-
)
603622
PASSWORD_HASHERS = [
604623
"django.contrib.auth.hashers.MD5PasswordHasher",
605624
]

src/helm/env.d/dev/values.impress.yaml.gotmpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ backend:
1515
DJANGO_EMAIL_HOST: "mailcatcher"
1616
DJANGO_EMAIL_PORT: 1025
1717
DJANGO_EMAIL_USE_SSL: False
18+
LOGGING_LEVEL_HANDLERS_CONSOLE: ERROR
19+
LOGGING_LEVEL_LOGGERS_ROOT: INFO
20+
LOGGING_LEVEL_LOGGERS_APP: INFO
1821
OIDC_OP_JWKS_ENDPOINT: https://fca.integ01.dev-agentconnect.fr/api/v2/jwks
1922
OIDC_OP_AUTHORIZATION_ENDPOINT: https://fca.integ01.dev-agentconnect.fr/api/v2/authorize
2023
OIDC_OP_TOKEN_ENDPOINT: https://fca.integ01.dev-agentconnect.fr/api/v2/token

0 commit comments

Comments
 (0)