-
Notifications
You must be signed in to change notification settings - Fork 604
Enhance logging configuration to separate console and error outputs #3704
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| import base64 | ||
| import json | ||
| import logging | ||
|
|
||
| from authlib.jose import JsonWebKey | ||
|
|
||
|
|
@@ -66,28 +67,42 @@ | |
| "formatters": { | ||
| "verbose": {"format": "%(levelname)s %(asctime)s %(module)s %(message)s"} | ||
| }, | ||
| "filters": { | ||
| "below_error": { | ||
| "()": "django.utils.log.CallbackFilter", | ||
| "callback": lambda record: record.levelno < logging.ERROR, | ||
| }, | ||
| }, | ||
| "handlers": { | ||
| "console": { | ||
| "level": "DEBUG", | ||
| "class": "logging.StreamHandler", | ||
| "stream": "ext://sys.stdout", | ||
| "formatter": "verbose", | ||
| } | ||
| "filters": ["below_error"], | ||
| }, | ||
| "console_error": { | ||
| "level": "ERROR", | ||
| "class": "logging.StreamHandler", | ||
| "stream": "ext://sys.stderr", | ||
| "formatter": "verbose", | ||
| }, | ||
| }, | ||
| "loggers": { | ||
| "django.request": { | ||
| "handlers": ["console"], | ||
| "handlers": ["console_error"], | ||
| "level": "ERROR", | ||
| }, | ||
| "audit_log": { | ||
| "handlers": ["console"], | ||
| "handlers": ["console_error"], | ||
| "level": "ERROR", | ||
| }, | ||
| "celery": { | ||
| "handlers": ["console"], | ||
| "handlers": ["console_error"], | ||
| "level": "ERROR", | ||
| }, | ||
| }, | ||
| "root": {"level": "INFO", "handlers": ["console"]}, | ||
| "root": {"level": "INFO", "handlers": ["console", "console_error"]}, | ||
|
Comment on lines
91
to
+105
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: git ls-files config/settings && printf '\n--- test.py ---\n' && sed -n '1,220p' config/settings/test.py && printf '\n--- deployment.py ---\n' && sed -n '1,260p' config/settings/deployment.pyRepository: ohcnetwork/care Length of output: 9939 Add 🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| CELERY_TASK_ALWAYS_EAGER = True | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
django.request,audit_log, andceleryloggers all send records directly toconsole_error, but none have"propagate": False. Because the root logger also includesconsole_error, every ERROR record from these loggers will be written to stderr twice — once by the logger's own handler and once by the root logger's handler. Thedeployment.pyloggers (django.db.backends,sentry_sdk) correctly use"propagate": Falseto prevent exactly this. Adding the same key to the three loggers intest.pywould fix the duplicate output.