Improve exception logging
This commit is contained in:
parent
0476bc7e31
commit
26cae32c0b
|
@ -7,6 +7,7 @@ import requests
|
||||||
import time
|
import time
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from rest_framework.exceptions import ValidationError
|
from rest_framework.exceptions import ValidationError
|
||||||
|
from rest_framework.views import exception_handler
|
||||||
from dateutil import relativedelta
|
from dateutil import relativedelta
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
from PIL import Image, ImageDraw, ImageFont, ImageOps
|
from PIL import Image, ImageDraw, ImageFont, ImageOps
|
||||||
|
@ -417,3 +418,9 @@ def gen_member_forms(member):
|
||||||
|
|
||||||
member.member_forms = file_name
|
member.member_forms = file_name
|
||||||
member.save()
|
member.save()
|
||||||
|
|
||||||
|
def custom_exception_handler(exc, context):
|
||||||
|
response = exception_handler(exc, context)
|
||||||
|
if response is not None:
|
||||||
|
logging.warning('Response: %s', json.dumps(exc.detail))
|
||||||
|
return response
|
||||||
|
|
|
@ -209,6 +209,7 @@ REST_FRAMEWORK = {
|
||||||
'DEFAULT_RENDERER_CLASSES': DEFAULT_RENDERER_CLASSES,
|
'DEFAULT_RENDERER_CLASSES': DEFAULT_RENDERER_CLASSES,
|
||||||
'DEFAULT_AUTHENTICATION_CLASSES': DEFAULT_AUTHENTICATION_CLASSES,
|
'DEFAULT_AUTHENTICATION_CLASSES': DEFAULT_AUTHENTICATION_CLASSES,
|
||||||
'DEFAULT_THROTTLE_CLASSES': ['apiserver.api.throttles.LoggingThrottle'],
|
'DEFAULT_THROTTLE_CLASSES': ['apiserver.api.throttles.LoggingThrottle'],
|
||||||
|
'EXCEPTION_HANDLER': 'apiserver.api.utils.custom_exception_handler'
|
||||||
}
|
}
|
||||||
|
|
||||||
#DEFAULT_LOGGING = None
|
#DEFAULT_LOGGING = None
|
||||||
|
|
Loading…
Reference in New Issue
Block a user