feat: dynamically handle root and procrastinate logs separately

This commit is contained in:
Herculino Trotta
2024-10-26 19:26:55 -03:00
parent f0c143cda1
commit 2a7b4dd729
+36 -1
View File
@@ -11,6 +11,7 @@ https://docs.djangoproject.com/en/5.1/ref/settings/
""" """
import os import os
import sys
from pathlib import Path from pathlib import Path
@@ -268,11 +269,14 @@ SPECTACULAR_SETTINGS = {
# OTHER SETTINGS # OTHER SETTINGS
} }
if "procrastinate" in sys.argv:
LOGGING = { LOGGING = {
"version": 1, "version": 1,
"disable_existing_loggers": False, "disable_existing_loggers": False,
"formatters": { "formatters": {
"procrastinate": {"format": "%(asctime)s %(levelname)-7s %(name)s %(message)s"}, "procrastinate": {
"format": "%(asctime)s %(levelname)-7s %(name)s %(message)s"
},
}, },
"handlers": { "handlers": {
"procrastinate": { "procrastinate": {
@@ -296,5 +300,36 @@ LOGGING = {
}, },
}, },
} }
else:
LOGGING = {
"version": 1,
"disable_existing_loggers": False,
"formatters": {
"procrastinate": {
"format": "%(asctime)s %(levelname)-7s %(name)s %(message)s"
},
},
"handlers": {
"procrastinate": {
"level": "DEBUG",
"class": "logging.StreamHandler",
"formatter": "procrastinate",
},
"console": {
"class": "logging.StreamHandler",
},
},
"loggers": {
"procrastinate": {
"handlers": None,
"level": "INFO",
"propagate": False,
},
"root": {
"handlers": ["console"],
"level": "INFO",
},
},
}
CACHALOT_UNCACHABLE_TABLES = ("django_migrations", "procrastinate_jobs") CACHALOT_UNCACHABLE_TABLES = ("django_migrations", "procrastinate_jobs")