Skip to content

Commit 3bbc124

Browse files
authored
Merge pull request #233 from TheLime1/add-logger-debug
Add _LOGGER.debug to XML response/request in Connection
2 parents 4b3c70f + c5667d6 commit 3bbc124

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

huawei_lte_api/Connection.py

+7
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
from typing import Optional, Tuple, Union, Type
44
from urllib.parse import urlparse
55

6+
import logging
67
import requests
78

89
from huawei_lte_api.Session import Session
910
from huawei_lte_api.api.User import UserSession, DEFAULT_USERNAME
1011

12+
_LOGGER = logging.getLogger(__name__)
13+
1114

1215
class Connection(Session):
1316
user_session: Optional[UserSession] = None
@@ -29,6 +32,10 @@ def __init__(self,
2932
username = username or parsed_url.username
3033
password = password if password else parsed_url.password
3134

35+
_LOGGER.debug("Initializing Connection with URL: %s", url)
36+
_LOGGER.debug("Username: %s", username)
37+
_LOGGER.debug("Password: %s", password)
38+
3239
super().__init__(url, timeout=timeout, requests_session=requests_session)
3340
if username or password:
3441
self.user_session = UserSession(

huawei_lte_api/Session.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,13 @@ def post_get(self,
200200
is_encrypted: bool = False,
201201
is_json: bool = False,
202202
) -> GetResponseType:
203-
return cast(
203+
_LOGGER.debug("Sending XML request to endpoint %s: %s", endpoint, data)
204+
response = cast(
204205
GetResponseType,
205206
self._post(endpoint, data, refresh_csrf, prefix, is_encrypted, is_json)
206207
)
208+
_LOGGER.debug("Received XML response from endpoint %s: %s", endpoint, response)
209+
return response
207210

208211
def post_set(self,
209212
endpoint: str,
@@ -213,10 +216,13 @@ def post_set(self,
213216
is_encrypted: bool = False,
214217
is_json: bool = False,
215218
) -> SetResponseType:
216-
return cast(
219+
_LOGGER.debug("Sending XML request to endpoint %s: %s", endpoint, data)
220+
response = cast(
217221
SetResponseType,
218222
self._post(endpoint, data, refresh_csrf, prefix, is_encrypted, is_json)
219223
)
224+
_LOGGER.debug("Received XML response from endpoint %s: %s", endpoint, response)
225+
return response
220226

221227
@_try_or_reload_and_retry
222228
def _post(self,

0 commit comments

Comments
 (0)