Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log incoming and outgoing information #135 #210

Merged
merged 1 commit into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions apps/util/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import logging
from datetime import datetime

from rest_framework.views import exception_handler


Expand All @@ -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
31 changes: 31 additions & 0 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,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"
Expand Down
Loading