From 6eca23e47461f2e34623563fe40aac60e8facb5d Mon Sep 17 00:00:00 2001 From: Simon Lamon <32477463+silamon@users.noreply.github.com> Date: Thu, 26 Sep 2024 20:03:05 +0000 Subject: [PATCH] Add debug logging --- src/linkplay/bridge.py | 8 +++++++- src/linkplay/consts.py | 3 +++ src/linkplay/utils.py | 2 -- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/linkplay/bridge.py b/src/linkplay/bridge.py index 4241b12..7776150 100644 --- a/src/linkplay/bridge.py +++ b/src/linkplay/bridge.py @@ -4,6 +4,7 @@ from linkplay.consts import ( INPUT_MODE_MAP, + LOGGER, PLAY_MODE_SEND_MAP, ChannelType, DeviceAttribute, @@ -280,10 +281,15 @@ def to_dict(self): async def json_request(self, command: str) -> dict[str, str]: """Performs a GET request on the given command and returns the result as a JSON object.""" - return await self.endpoint.json_request(command) + LOGGER.debug(str.format("Request command at {}: {}", self.endpoint, command)) + response = await self.endpoint.json_request(command) + LOGGER.debug(str.format("Response command {}: {}", command, response)) + return response async def request(self, command: str) -> None: """Performs a GET request on the given command and verifies the result.""" + + LOGGER.debug(str.format("Request command at {}: {}", self.endpoint, command)) await self.endpoint.request(command) diff --git a/src/linkplay/consts.py b/src/linkplay/consts.py index 31fd4ad..8856bac 100644 --- a/src/linkplay/consts.py +++ b/src/linkplay/consts.py @@ -1,5 +1,8 @@ +import logging from enum import IntFlag, StrEnum +LOGGER = logging.getLogger("linkplay") + API_ENDPOINT: str = "{}/httpapi.asp?command={}" API_TIMEOUT: int = 2 UNKNOWN_TRACK_PLAYING: str = "Unknown" diff --git a/src/linkplay/utils.py b/src/linkplay/utils.py index 918478d..2e3ce8d 100644 --- a/src/linkplay/utils.py +++ b/src/linkplay/utils.py @@ -24,8 +24,6 @@ ) from linkplay.exceptions import LinkPlayRequestException -_LOGGER = logging.getLogger(__name__) - async def session_call_api(endpoint: str, session: ClientSession, command: str) -> str: """Calls the LinkPlay API and returns the result as a string.