Skip to content

Commit

Permalink
Merge pull request #5 from retresco/feature/x-forward_in_log_msg
Browse files Browse the repository at this point in the history
feature/x forward in log msg
  • Loading branch information
drotschmann committed Mar 17, 2017
2 parents e1b727b + 852fb8f commit c66061c
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions supercell/requesthandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,17 @@ def request_id(self):
return self._request_id

def _request_summary(self):
return self.request.method + " " + self.request.uri + \
" (ip:" + self.request.remote_ip + ", r_id:" + \
str(self.request_id) + ")"
"""Returns a summery of method, uri, caller ip and request id.
If request is forwarded by a proxy and X-Forwarded-For header is set,
the ip from this header is use as caller ip.
The message is mainly used for log messages."""
x_forward = self.request.headers.get('X-Forwarded-For', None)
return '{method} {uri} (ip:{r_ip}, r_id:{r_id})'.format(
method=self.request.method,
uri=self.request.uri,
r_ip=x_forward or self.request.remote_ip,
r_id=str(self.request_id),
)

def get_template(self, model):
"""Method to determine which template to use for rendering the html.
Expand Down

0 comments on commit c66061c

Please sign in to comment.