Skip to content

Commit

Permalink
Add debug logging (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
silamon authored Sep 29, 2024
1 parent cdfdf55 commit 87cf9b6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/linkplay/bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from linkplay.consts import (
INPUT_MODE_MAP,
LOGGER,
PLAY_MODE_SEND_MAP,
ChannelType,
DeviceAttribute,
Expand Down Expand Up @@ -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)


Expand Down
3 changes: 3 additions & 0 deletions src/linkplay/consts.py
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 0 additions & 2 deletions src/linkplay/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 87cf9b6

Please sign in to comment.