Skip to content
This repository was archived by the owner on Dec 14, 2025. It is now read-only.

Commit f1ee529

Browse files
authored
feat: add debug logging to proxy requests (#22)
* feat: add debug logging to proxy requests * fix: tox
1 parent ac7b281 commit f1ee529

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

aiocloudweather/proxy.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
"""Proxy for forwarding data to the CloudWeather APIs."""
22

33
from enum import Enum
4+
import logging
45
from aiohttp import web, TCPConnector, ClientSession
56
from urllib.parse import quote
67
from aiohttp.resolver import AsyncResolver
78

9+
_LOGGER = logging.getLogger(__name__)
10+
811

912
class DataSink(Enum):
1013
"""Data sinks for the CloudWeather API."""
@@ -30,12 +33,14 @@ async def forward_wunderground(self, request: web.Request) -> web.Response:
3033
"""Forward Wunderground data to their API."""
3134
query_string = quote(request.query_string).replace("%20", "+")
3235
url = f"https://rtupdate.wunderground.com/weatherstation/updateweatherstation.php?{query_string}"
36+
_LOGGER.debug("Forwarding Wunderground data: %s", url)
3337
return await self.session.get(url)
3438

3539
async def forward_weathercloud(self, request: web.Request) -> web.Response:
3640
"""Forward WeatherCloud data to their API."""
3741
new_path = request.path[request.path.index("/v01/set") :]
3842
url = f"https://api.weathercloud.net{new_path}"
43+
_LOGGER.debug("Forwarding WeatherCloud data: %s", url)
3944
return await self.session.get(url)
4045

4146
async def forward(self, sink: DataSink, request: web.Request) -> web.Response:

pytest.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[pytest]
2+
asyncio_default_fixture_loop_scope = function

tests/test_server.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import asyncio
21
import pytest
32
from aiohttp import web
43
from aiocloudweather.server import CloudWeatherListener

0 commit comments

Comments
 (0)