Skip to content

Commit

Permalink
chore(client): log response headers in debug mode (#1383)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot committed Apr 29, 2024
1 parent c558f65 commit f31a426
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/openai/_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,8 @@ def _request(
if self.custom_auth is not None:
kwargs["auth"] = self.custom_auth

log.debug("Sending HTTP Request: %s %s", request.method, request.url)

try:
response = self._client.send(
request,
Expand Down Expand Up @@ -984,8 +986,14 @@ def _request(
raise APIConnectionError(request=request) from err

log.debug(
'HTTP Request: %s %s "%i %s"', request.method, request.url, response.status_code, response.reason_phrase
'HTTP Response: %s %s "%i %s" %s',
request.method,
request.url,
response.status_code,
response.reason_phrase,
response.headers,
)
log.debug("request_id: %s", response.headers.get("x-request-id"))

try:
response.raise_for_status()
Expand Down

0 comments on commit f31a426

Please sign in to comment.