Enhance logging configuration in WSGI setup for better debugging and error handling

This commit is contained in:
Ross
2026-03-02 11:04:51 +00:00
parent b3f5684e69
commit 12e3d47600
2 changed files with 71 additions and 4 deletions
+3 -1
View File
@@ -34,12 +34,14 @@ try:
enqueue=True,
serialize=True,
)
logger.debug("Loguru logging configured with stdout and file sinks")
except Exception:
# Best-effort only — don't crash WSGI startup if logging can't be configured
try:
logger.add(sys.stderr)
logger.add(sys.stderr, level="DEBUG", enqueue=True, backtrace=False, diagnose=False)
except Exception:
pass
logger.debug("Failed to configure Loguru logging sinks, continuing without file logging")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "rad.settings")