mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-10-14 11:28:02 +00:00
Avoid calling pformat unless debug logging is enabled (#217)
* Avoid calling pformat unless debug logging is enabled * add logging test * isort * check for debug logging * formatting
This commit is contained in:
@@ -90,8 +90,10 @@ class TPLinkSmartHomeProtocol:
|
||||
"""Execute a query on the device and wait for the response."""
|
||||
assert self.writer is not None
|
||||
assert self.reader is not None
|
||||
debug_log = _LOGGER.isEnabledFor(logging.DEBUG)
|
||||
|
||||
_LOGGER.debug("> (%i) %s", len(request), request)
|
||||
if debug_log:
|
||||
_LOGGER.debug("> (%i) %s", len(request), request)
|
||||
self.writer.write(TPLinkSmartHomeProtocol.encrypt(request))
|
||||
await self.writer.drain()
|
||||
|
||||
@@ -101,7 +103,8 @@ class TPLinkSmartHomeProtocol:
|
||||
buffer = await self.reader.readexactly(length)
|
||||
response = TPLinkSmartHomeProtocol.decrypt(buffer)
|
||||
json_payload = json.loads(response)
|
||||
_LOGGER.debug("< (%i) %s", len(response), pf(json_payload))
|
||||
if debug_log:
|
||||
_LOGGER.debug("< (%i) %s", len(response), pf(json_payload))
|
||||
return json_payload
|
||||
|
||||
async def close(self):
|
||||
|
Reference in New Issue
Block a user