1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-18 12:28:09 +00:00

feat(python): more compact debuglink logging

[no changelog]
This commit is contained in:
Martin Milata 2024-04-09 13:34:49 +02:00
parent a873a7064e
commit b1c670090a

View File

@ -424,9 +424,16 @@ class DebugLink:
f"received type {msg_type} ({len(msg_bytes)} bytes): {msg_bytes.hex()}", f"received type {msg_type} ({len(msg_bytes)} bytes): {msg_bytes.hex()}",
) )
msg = self.mapping.decode(ret_type, ret_bytes) msg = self.mapping.decode(ret_type, ret_bytes)
# Collapse tokens to make log use less lines.
msg_for_log = msg
if isinstance(msg, (messages.DebugLinkState, messages.DebugLinkLayout)):
msg_for_log = deepcopy(msg)
msg_for_log.tokens = ["".join(msg_for_log.tokens)]
LOG.debug( LOG.debug(
f"received message: {msg.__class__.__name__}", f"received message: {msg_for_log.__class__.__name__}",
extra={"protobuf": msg}, extra={"protobuf": msg_for_log},
) )
return msg return msg