mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 18:09:57 -03: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:
parent
f56b716b8f
commit
e197bfeb01
@ -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.
|
||||
|
||||
@ -142,7 +142,7 @@ class JobTemplateCallbackPermission(ModelAccessPermission):
|
||||
# True to fall through to the next permission class.
|
||||
if (request.user or request.auth) and request.method.lower() != 'post':
|
||||
return super(JobTemplateCallbackPermission, self).has_permission(request, view, obj)
|
||||
|
||||
|
||||
# Require method to be POST, host_config_key to be specified and match
|
||||
# the requested job template, and require the job template to be
|
||||
# active in order to proceed.
|
||||
|
||||
@ -404,13 +404,27 @@ LOGGING = {
|
||||
'filters': ['require_debug_false'],
|
||||
'class': 'django.utils.log.AdminEmailHandler',
|
||||
},
|
||||
'rotating_file': {
|
||||
'level': 'WARNING',
|
||||
'class':'logging.handlers.RotatingFileHandler',
|
||||
'filters': ['require_debug_false'],
|
||||
'filename': os.path.join(BASE_DIR, 'tower_warnings.log'),
|
||||
'maxBytes': 1024*1024*5, # 5 MB
|
||||
'backupCount': 5,
|
||||
'formatter':'simple',
|
||||
},
|
||||
},
|
||||
'loggers': {
|
||||
'django': {
|
||||
'handlers': ['console'],
|
||||
},
|
||||
'django.request': {
|
||||
'handlers': ['mail_admins', 'console', 'file', 'syslog'],
|
||||
'handlers': ['mail_admins', 'console', 'file', 'syslog', 'rotating_file'],
|
||||
'level': 'WARNING',
|
||||
'propagate': False,
|
||||
},
|
||||
'rest_framework.request': {
|
||||
'handlers': ['mail_admins', 'console', 'file', 'syslog', 'rotating_file'],
|
||||
'level': 'WARNING',
|
||||
'propagate': False,
|
||||
},
|
||||
@ -418,7 +432,7 @@ LOGGING = {
|
||||
'handlers': ['console'],
|
||||
},
|
||||
'awx': {
|
||||
'handlers': ['console', 'file', 'syslog'],
|
||||
'handlers': ['console', 'file', 'syslog', 'rotating_file'],
|
||||
'level': 'DEBUG',
|
||||
},
|
||||
'awx.main.access': {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user