Skip to content

Commit

Permalink
Improve logging in request method (#411)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kane610 committed Jul 23, 2023
1 parent 81e3e88 commit 83716f2
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions aiounifi/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ async def _request(
"""Make a request to the API."""
self.last_response = None

LOGGER.debug("%s", url)
LOGGER.debug("sending (to %s) %s, %s, %s", url, method, json, kwargs)

try:
async with self.session.request(
Expand All @@ -209,7 +209,13 @@ async def _request(
headers=self.headers,
**kwargs,
) as res:
LOGGER.debug("%s %s %s", res.status, res.content_type, res)
LOGGER.debug(
"received (from %s) %s %s %s",
url,
res.status,
res.content_type,
res,
)

self.last_response = res

Expand All @@ -232,6 +238,7 @@ async def _request(

if res.content_type == "application/json":
response = await res.json()
LOGGER.debug("data (from %s) %s", url, response)
_raise_on_error(response)
if "data" in response:
return response["data"]
Expand Down

0 comments on commit 83716f2

Please sign in to comment.