Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Log Python warning using JSON logging configuration (#10563)

Mikadf92942da77d
diff --git a/saleor/settings.py b/saleor/settings.py
index 6a9addd7e8..fe02d73e07 100644
--- a/saleor/settings.py
+++ b/saleor/settings.py
@@ -1,4 +1,5 @@
import ast
+import logging
import os.path
import warnings
from datetime import timedelta
@@ -284,6 +285,10 @@ if ENABLE_DEBUG_TOOLBAR:
]
DEBUG_TOOLBAR_CONFIG = {"RESULTS_CACHE_SIZE": 100}
+# Make the `logging` Python module capture `warnings.warn()` calls
+# This is needed in order to log them as JSON when DEBUG=False
+logging.captureWarnings(True)
+
LOGGING = {
"version": 1,
"disable_existing_loggers": False,