def log_request(self): # gevent.pywsgi tries to call log.write(), but Python logger objects # implement log.debug(), log.info(), etc., so we need to monkey-patch # log_request(). See # http://stackoverflow.com/questions/9444405/gunicorn-and-websockets log = self.server.log length = self.response_length if self.time_finish: request_time = round(self.time_finish - self.time_start, 6) if isinstance(self.client_address, tuple): client_address = self.client_address[0] else: client_address = self.client_address # client_address is '' when requests are forwarded from nginx via # Unix socket. In that case, replace with a meaningful value if client_address == '': client_address = self.headers.get('X-Forward-For') status = getattr(self, 'status', None) requestline = getattr(self, 'requestline', None) additional_context = self.environ.get('log_context') or {} log.info('request handled', length=length, request_time=request_time, client_address=client_address, status=status, requestline=requestline, **additional_context)
def log_request(self): # gevent.pywsgi tries to call log.write(), but Python logger objects # implement log.debug(), log.info(), etc., so we need to monkey-patch # log_request(). See # http://stackoverflow.com/questions/9444405/gunicorn-and-websockets log = self.server.log length = self.response_length if self.time_finish: request_time = round(self.time_finish - self.time_start, 6) if isinstance(self.client_address, tuple): client_address = self.client_address[0] else: client_address = self.client_address # client_address is None when requests are forwarded from nginx via # Unix socket. In that case, replace with a menaingful value if client_address is None: client_address = self.headers.get('X-Forward-For') status = getattr(self, 'status', None) requestline = getattr(self, 'requestline', None) additional_context = self.environ.get('log_context') or {} log.info('request handled', length=length, request_time=request_time, client_address=client_address, status=status, requestline=requestline, **additional_context)
def log_request(self): # gevent.pywsgi tries to call log.write(), but Python logger objects # implement log.debug(), log.info(), etc., so we need to monkey-patch # log_request(). See # http://stackoverflow.com/questions/9444405/gunicorn-and-websockets log = self.server.log length = self.response_length if self.time_finish: request_time = round(self.time_finish - self.time_start, 6) if isinstance(self.client_address, tuple): client_address = self.client_address[0] else: client_address = self.client_address status = getattr(self, 'status', None) requestline = getattr(self, 'requestline', None) log.info('request handled', length=length, request_time=request_time, client_address=client_address, status=status, requestline=requestline)