Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add debug logging #49

Merged
merged 1 commit into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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