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"
|
assert self._transport is not None, "Transport should be set"
|
||||||
data = b"\0" + varuint_to_bytes(len(data)) + varuint_to_bytes(type_) + data
|
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:
|
try:
|
||||||
self._transport.write(data)
|
self._transport.write(data)
|
||||||
|
|
|
@ -531,7 +531,11 @@ class APIConnection:
|
||||||
if not message_type:
|
if not message_type:
|
||||||
raise ValueError(f"Message type id not found for type {type(msg)}")
|
raise ValueError(f"Message type id not found for type {type(msg)}")
|
||||||
encoded = msg.SerializeToString()
|
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:
|
try:
|
||||||
frame_helper.write_packet(message_type, encoded)
|
frame_helper.write_packet(message_type, encoded)
|
||||||
|
|
Loading…
Reference in New Issue