Skip to content

Commit

Permalink
🐛 [#34] Properly log data for error responses
Browse files Browse the repository at this point in the history
this previously failed because truthy checks on Response evaluates to false for error responses
  • Loading branch information
stevenbal committed Feb 8, 2024
1 parent 978b593 commit f7f566b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions log_outgoing_requests/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,18 @@ def emit(self, record: AnyLogRecord):
"url": request.url if request else "(unknown)",
"hostname": parsed_url.netloc if parsed_url else "(unknown)",
"params": parsed_url.params if parsed_url else "(unknown)",
"status_code": response.status_code if response else None,
"status_code": response.status_code if response is not None else None,
"method": request.method if request else "(unknown)",
"timestamp": timestamp,
"response_ms": int(response.elapsed.total_seconds() * 1000)
if response
if response is not None
else 0,
"req_headers": self.format_headers(scrubbed_req_headers),
"res_headers": self.format_headers(response.headers if response else {}),
"res_headers": self.format_headers(response.headers if response is not None else {}),
"trace": "\n".join(format_exception(exception)) if exception else "",
}


if config.save_body_enabled:
# check request
if (
Expand Down

0 comments on commit f7f566b

Please sign in to comment.