root(minor): disable uwsgi request loggin and use custom logging instead

This commit is contained in:
Langhammer, Jens 2019-10-15 15:57:37 +02:00
parent d4cb1a98c7
commit 3353aa0298
2 changed files with 9 additions and 10 deletions

View File

@ -8,3 +8,4 @@ threads = 2
enable-threads = true enable-threads = true
uid = passbook uid = passbook
gid = passbook gid = passbook
disable-logging=True

View File

@ -14,14 +14,12 @@ from structlog import get_logger
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "passbook.root.settings") os.environ.setdefault("DJANGO_SETTINGS_MODULE", "passbook.root.settings")
LOGGER = get_logger()
class WSGILogger: class WSGILogger:
""" This is the generalized WSGI middleware for any style request logging. """ """ This is the generalized WSGI middleware for any style request logging. """
def __init__(self, application): def __init__(self, application):
self.application = application self.application = application
self.logger = get_logger('passbook.wsgi')
def __healthcheck(self, start_response): def __healthcheck(self, start_response):
start_response('204 OK', []) start_response('204 OK', [])
@ -64,13 +62,13 @@ class WSGILogger:
query_string = '' query_string = ''
if environ.get('QUERY_STRING') != '': if environ.get('QUERY_STRING') != '':
query_string = f"?{environ.get('QUERY_STRING')}" query_string = f"?{environ.get('QUERY_STRING')}"
LOGGER.info(f"{environ.get('PATH_INFO', '')}{query_string}", self.logger.info(f"{environ.get('PATH_INFO', '')}{query_string}",
host=host, host=host,
method=environ.get('REQUEST_METHOD', ''), method=environ.get('REQUEST_METHOD', ''),
protocol=environ.get('SERVER_PROTOCOL', ''), protocol=environ.get('SERVER_PROTOCOL', ''),
status=status_code, status=status_code,
size=content_length / 1000 if content_length > 0 else '-', size=content_length / 1000 if content_length > 0 else '-',
runtime=kwargs.get('runtime')) runtime=kwargs.get('runtime'))
application = WSGILogger(get_wsgi_application()) application = WSGILogger(get_wsgi_application())