Skip to content

Commit

Permalink
feat: Add debug logging support
Browse files Browse the repository at this point in the history
  • Loading branch information
dermotduffy committed Nov 24, 2024
1 parent fe5997e commit ed0e3fc
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions custom_components/hass_web_proxy/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import urlmatch
import voluptuous as vol
from hass_web_proxy_lib import (
LOGGER,
HASSWebProxyLibNotFoundRequestError,
ProxiedURL,
ProxyView,
Expand Down Expand Up @@ -110,6 +111,9 @@ def create_proxied_url(call: ServiceCall) -> ServiceResponse:
expiration=time.time() + ttl if ttl else 0,
allow_unauthenticated=call.data["allow_unauthenticated"],
)

LOGGER.debug(f"Created dynamically proxied URL '{url_id}': {call.data}")

return {"url_id": url_id}

def delete_proxied_url(call: ServiceCall) -> None:
Expand All @@ -125,6 +129,8 @@ def delete_proxied_url(call: ServiceCall) -> None:
)
del entry.runtime_data.dynamic_proxied_urls[url_id]

LOGGER.debug(f"Deleted dynamically proxied URL '{url_id}'")

if entry.options.get(CONF_DYNAMIC_URLS):
hass.services.async_register(
DOMAIN,
Expand Down Expand Up @@ -180,6 +186,12 @@ def _cleanup_expired_urls(self) -> None:

def _get_proxied_url(self, request: web.Request, **_kwargs: Any) -> ProxiedURL:
"""Get the URL to proxy."""
LOGGER.debug(
f"Received proxy request '{request.query}',"
f" dynamic proxied URLs: {self.get_dynamic_proxied_urls()},"
f" static options: {self._get_options()}."
)

if "url" not in request.query:
raise HASSWebProxyLibNotFoundRequestError

Expand Down

0 comments on commit ed0e3fc

Please sign in to comment.