From a804ad6f0cb14dfcce30b7ac3262e64c5a2f09c7 Mon Sep 17 00:00:00 2001 From: Tomasz Knapik Date: Tue, 26 Nov 2024 15:08:11 +0000 Subject: [PATCH] Add logging config --- config/settings/base.py | 48 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/config/settings/base.py b/config/settings/base.py index 793159c..c63b7f0 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -116,6 +116,54 @@ DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" + +# Logging +# https://docs.djangoproject.com/en/stable/topics/logging/ +LOGGING = { + "version": 1, + "disable_existing_loggers": False, + "handlers": { + # Send logs with at least INFO level to the console. + "console": { + "level": "INFO", + "class": "logging.StreamHandler", + "formatter": "verbose", + }, + }, + "formatters": { + "verbose": { + "format": "[%(asctime)s][%(process)d][%(levelname)s][%(name)s] %(message)s" + } + }, + "root": { + "handlers": ["console"], + "level": "WARNING", + }, + "loggers": { + "app": { + "handlers": ["console"], + "level": "INFO", + "propagate": False, + }, + "config": { + "handlers": ["console"], + "level": "INFO", + "propagate": False, + }, + "django.request": { + "handlers": ["console"], + "level": "WARNING", + "propagate": False, + }, + "django.security": { + "handlers": ["console"], + "level": "WARNING", + "propagate": False, + }, + }, +} + + # TNA Configuration ENVIRONMENT: str = os.environ.get("ENVIRONMENT", "production")