diff --git a/apps/util/exceptions.py b/apps/util/exceptions.py index e7781c6..1a6c27c 100644 --- a/apps/util/exceptions.py +++ b/apps/util/exceptions.py @@ -1,3 +1,6 @@ +import logging +from datetime import datetime + from rest_framework.views import exception_handler @@ -9,4 +12,7 @@ def custom_exception_handler(exc, context): response.data = data response.content_type = "application/json" + logging.getLogger("nau_financial_manager").error( + f"time:{datetime.now()}, error: {response.data}, exc: '{exc}', context: {context}" + ) return response diff --git a/nau_financial_manager/settings.py b/nau_financial_manager/settings.py index ef52ea1..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,6 +218,36 @@ def get_env_setting(env_variable, default=None): }, ] + +LOGGING = CONFIG.get( + "LOGGING", + { + "version": 1, + "disable_existing_loggers": False, + "handlers": { + "console": { + "level": "ERROR", + "class": "logging.StreamHandler", + }, + }, + "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" TIME_ZONE = "UTC"