mirror of
https://github.com/esphome/aioesphomeapi.git
synced 2024-12-24 17:08:01 +01:00
Add checks for debug logging in the write path (#458)
This commit is contained in:
parent
87e580914f
commit
69b4c42cf3
@ -139,7 +139,8 @@ 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
|
||||
_LOGGER.debug("Sending plaintext frame %s", data.hex())
|
||||
if _LOGGER.isEnabledFor(logging.DEBUG):
|
||||
_LOGGER.debug("Sending plaintext frame %s", data.hex())
|
||||
|
||||
try:
|
||||
self._transport.write(data)
|
||||
|
@ -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