Skip to content

Commit

Permalink
reformat response text and headers in error logging on RequestHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
geo-martino committed May 25, 2024
1 parent 01143d5 commit a6fd77d
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions musify/api/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,9 @@ async def _log_response(self, response: ClientResponse, method: str, url: str |
if isinstance(response.headers, Mapping): # format headers if JSON
response_headers = json.dumps(dict(response.headers), indent=2)
self.logger.warning(
f"\33[91m{method.upper():<7}: {url} | Code: {response.status} | "
f"Response text and headers follow:\n"
f"Response text:\n{await response.text()}\n"
f"Headers:\n{response_headers}\33[0m"
f"\33[91m{method.upper():<7}: {url} | Code: {response.status} | Response text and headers follow:\n"
f"Response text:\n\t{(await response.text()).replace("\n", "\n\t")}\n"
f"Headers:\n\t{response_headers.replace("\n", "\n\t")}\33[0m"
)

async def _handle_unexpected_response(self, response: ClientResponse) -> bool:
Expand Down

0 comments on commit a6fd77d

Please sign in to comment.