Skip to content

Commit

Permalink
feat: get logging configuration from environment
Browse files Browse the repository at this point in the history
  • Loading branch information
Tiago-da-silva23 committed Dec 12, 2023
1 parent c2e8c0f commit 1391a0e
Showing 1 changed file with 26 additions and 24 deletions.
50 changes: 26 additions & 24 deletions nau_financial_manager/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"""
import codecs
import copy
import logging.config
import os
from pathlib import Path

Expand Down Expand Up @@ -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"

Expand Down

0 comments on commit 1391a0e

Please sign in to comment.