mirror of
https://github.com/ansible/awx.git
synced 2026-03-14 15:37:29 -02:30
Add a specific tower warnings file in the tower home directory.
Configure the api viewer to emit warnings for 4XX and 5XX status codes into that file. Configure it for use on a production system. Closes AC-685
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
# Python
|
||||
import inspect
|
||||
import logging
|
||||
import json
|
||||
|
||||
# Django
|
||||
@@ -31,6 +32,8 @@ __all__ = ['APIView', 'GenericAPIView', 'ListAPIView', 'SimpleListAPIView',
|
||||
'RetrieveAPIView', 'RetrieveUpdateAPIView',
|
||||
'RetrieveDestroyAPIView', 'RetrieveUpdateDestroyAPIView']
|
||||
|
||||
logger = logging.getLogger('awx.api.generics')
|
||||
|
||||
def get_view_name(cls, suffix=None):
|
||||
'''
|
||||
Wrapper around REST framework get_view_name() to support get_name() method
|
||||
@@ -131,6 +134,11 @@ class APIView(views.APIView):
|
||||
ret['added_in_version'] = added_in_version
|
||||
return ret
|
||||
|
||||
def finalize_response(self, request, response, *args, **kwargs):
|
||||
if response.status_code >= 400:
|
||||
logger.warn("status %s received by user %s attempting to access %s" % (response.status_code, request.user, request.path))
|
||||
return super(APIView, self).finalize_response(request, response, *args, **kwargs)
|
||||
|
||||
|
||||
class GenericAPIView(generics.GenericAPIView, APIView):
|
||||
# Base class for all model-based views.
|
||||
|
||||
Reference in New Issue
Block a user