From 1391a0e71a1d56e851f2055b934cea617564b709 Mon Sep 17 00:00:00 2001 From: Tiago-da-Silva23 Date: Tue, 12 Dec 2023 11:36:19 +0000 Subject: [PATCH] feat: get logging configuration from environment --- nau_financial_manager/settings.py | 50 ++++++++++++++++--------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/nau_financial_manager/settings.py b/nau_financial_manager/settings.py index 5d75f5b..29d6279 100644 --- a/nau_financial_manager/settings.py +++ b/nau_financial_manager/settings.py @@ -11,6 +11,7 @@ """ import codecs import copy +import logging.config import os from pathlib import Path @@ -217,34 +218,35 @@ def get_env_setting(env_variable, default=None): }, ] -LOGGING = { - "version": 1, - "disable_existing_loggers": False, - "handlers": { - "file": { - "level": "ERROR", - "class": "logging.FileHandler", - "filename": f"{BASE_DIR}/nau_financial_manager_file.log", - }, - "console": { - "level": "ERROR", - "class": "logging.StreamHandler", - }, - }, - "loggers": { - "django": { - "handlers": ["file", "console"], - "level": "ERROR", - "propagate": True, + +LOGGING = CONFIG.get( + "LOGGING", + { + "version": 1, + "disable_existing_loggers": False, + "handlers": { + "console": { + "level": "ERROR", + "class": "logging.StreamHandler", + }, }, - "nau_financial_manager": { - "handlers": ["file", "console"], - "level": "ERROR", - "propagate": True, + "loggers": { + "django": { + "handlers": ["console"], + "level": "ERROR", + "propagate": True, + }, + "nau_financial_manager": { + "handlers": ["console"], + "level": "ERROR", + "propagate": True, + }, }, }, -} +) +LOGGING_CONFIG = None +logging.config.dictConfig(LOGGING) LANGUAGE_CODE = "en-us"