mirror of
https://github.com/esphome/aioesphomeapi.git
synced 2024-12-25 17:17:42 +01:00
Add checks for debug logging in the write path (#458)
This commit is contained in:
parent
87e580914f
commit
69b4c42cf3
@ -139,6 +139,7 @@ class APIPlaintextFrameHelper(APIFrameHelper):
|
||||
"""
|
||||
assert self._transport is not None, "Transport should be set"
|
||||
data = b"\0" + varuint_to_bytes(len(data)) + varuint_to_bytes(type_) + data
|
||||
if _LOGGER.isEnabledFor(logging.DEBUG):
|
||||
_LOGGER.debug("Sending plaintext frame %s", data.hex())
|
||||
|
||||
try:
|
||||
|
@ -531,7 +531,11 @@ class APIConnection:
|
||||
if not message_type:
|
||||
raise ValueError(f"Message type id not found for type {type(msg)}")
|
||||
encoded = msg.SerializeToString()
|
||||
_LOGGER.debug("%s: Sending %s: %s", self._params.address, type(msg), str(msg))
|
||||
|
||||
if _LOGGER.isEnabledFor(logging.DEBUG):
|
||||
_LOGGER.debug(
|
||||
"%s: Sending %s: %s", self._params.address, type(msg), str(msg)
|
||||
)
|
||||
|
||||
try:
|
||||
frame_helper.write_packet(message_type, encoded)
|
||||
|
Loading…
Reference in New Issue
Block a user