Skip to content

Commit

Permalink
Improved debug logging.
Browse files Browse the repository at this point in the history
Bumped version
  • Loading branch information
sander1988 committed May 24, 2024
1 parent c817b7e commit d10caaa
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
21 changes: 18 additions & 3 deletions pyIndego/indego_async_client.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""API for Bosch API server for Indego lawn mower."""
import asyncio
import logging
import json
from socket import error as SocketError
from typing import Any, Optional, Callable, Awaitable

Expand Down Expand Up @@ -494,7 +495,13 @@ async def _request( # noqa: C901
headers["Authorization"] = "Bearer %s" % self._token

try:
_LOGGER.debug("%s call to API endpoint %s", method.value, url)
_LOGGER.debug(
"%s call to API endpoint %s, headers: %s, data: %s",
method.value,
url,
json.dumps(headers) if headers is not None else '',
json.dumps(data) if data is not None else '',
)
async with self._session.request(
method=method.value,
url=url,
Expand All @@ -507,9 +514,17 @@ async def _request( # noqa: C901
if status == 200:
if response.content_type == CONTENT_TYPE_JSON:
resp = await response.json()
_LOGGER.debug("Response: %s", resp)
_LOGGER.debug("Response (JSON): %s", resp)
return resp
return await response.content.read()

resp = await response.content.read()
if len(resp) < 1000:
_LOGGER.debug("Response (raw): %s", resp)
else:
_LOGGER.debug("Response (raw): Not logged, exceeds 1000 characters")

if status == 200:
return resp

if self._log_request_result(status, url):
return None
Expand Down
2 changes: 1 addition & 1 deletion pyIndego/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "3.1.3"
__version__ = "3.1.4"

0 comments on commit d10caaa

Please sign in to comment.