From d82edfe500f41a48d1270f6afc462949390be3d5 Mon Sep 17 00:00:00 2001 From: Josef Zweck <24647999+zweckj@users.noreply.github.com> Date: Sat, 23 Nov 2024 12:12:05 +0100 Subject: [PATCH] improve debug logging --- pylamarzocco/client_cloud.py | 7 ++++++- pyproject.toml | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pylamarzocco/client_cloud.py b/pylamarzocco/client_cloud.py index cf542d5..c026a88 100644 --- a/pylamarzocco/client_cloud.py +++ b/pylamarzocco/client_cloud.py @@ -70,6 +70,7 @@ async def _async_get_access_token(self) -> str: "client_id": DEFAULT_CLIENT_ID, "client_secret": DEFAULT_CLIENT_SECRET, } + _LOGGER.debug("Getting new access token, data: %s", data) return await self.__async_get_token(data) async def _async_get_refresh_token(self) -> str: @@ -81,6 +82,7 @@ async def _async_get_refresh_token(self) -> str: "client_id": DEFAULT_CLIENT_ID, "client_secret": DEFAULT_CLIENT_SECRET, } + _LOGGER.debug("Refreshing access token, data: %s", data) return await self.__async_get_token(data) async def __async_get_token(self, data: dict[str, Any]) -> str: @@ -100,6 +102,7 @@ async def __async_get_token(self, data: dict[str, Any]) -> str: refresh_token=json_response["refresh_token"], expires_in=time.time() + json_response["expires_in"], ) + _LOGGER.debug("Got new access token: %s", json_response) return json_response["access_token"] if response.status_code == 401: @@ -151,7 +154,9 @@ async def _rest_api_call( # ensure status code indicates success if response.is_success: - return response.json()["data"] + json_response = response.json() + _LOGGER.debug("Request to %s successful", json_response) + return json_response["data"] raise RequestNotSuccessful( f"Request to endpoint {response.url} failed with status code {response.status_code}" diff --git a/pyproject.toml b/pyproject.toml index d146354..7b6b6ce 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "pylamarzocco" -version = "1.2.10" +version = "1.2.11" license = { text = "MIT License" } description = "A Python implementation of the new La Marzocco API" readme = "README.md"