Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wsgi: move write access log info to own function #382

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 19 additions & 11 deletions eventlet/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,17 +554,12 @@ def start_response(status, response_headers, exc_info=None):
hook(self.environ, *args, **kwargs)

if self.server.log_output:
client_host, client_port = self.get_client_address()

self.server.log.info(self.server.log_format % {
'client_ip': client_host,
'client_port': client_port,
'date_time': self.log_date_time_string(),
'request_line': self.requestline,
'status_code': status_code[0],
'body_length': length[0],
'wall_seconds': finish - start,
})
self.write_access_log(
status_code=status_code[0],
body_length=length[0],
wall_seconds=finish - start,
headers=headers_set[1]
)

def get_client_address(self):
host, port = addr_to_host_port(self.client_address)
Expand All @@ -575,6 +570,19 @@ def get_client_address(self):
host = forward + ',' + host
return (host, port)

def write_access_log(self, **kwargs):
client_host, client_port = self.get_client_address()

self.server.log.info(self.server.log_format % {
'client_ip': client_host,
'client_port': client_port,
'date_time': self.log_date_time_string(),
'request_line': self.requestline,
'status_code': kwargs['status_code'],
'body_length': kwargs['body_length'],
'wall_seconds': kwargs['wall_seconds'],
})

def get_environ(self):
env = self.server.get_environ()
env['REQUEST_METHOD'] = self.command
Expand Down