From b1c670090ad2bd2d637ccce79c1ee64e4f2aae85 Mon Sep 17 00:00:00 2001 From: Martin Milata Date: Tue, 9 Apr 2024 13:34:49 +0200 Subject: [PATCH] feat(python): more compact debuglink logging [no changelog] --- python/src/trezorlib/debuglink.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/python/src/trezorlib/debuglink.py b/python/src/trezorlib/debuglink.py index dabf5694e..914ee5b66 100644 --- a/python/src/trezorlib/debuglink.py +++ b/python/src/trezorlib/debuglink.py @@ -424,9 +424,16 @@ class DebugLink: f"received type {msg_type} ({len(msg_bytes)} bytes): {msg_bytes.hex()}", ) 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( - f"received message: {msg.__class__.__name__}", - extra={"protobuf": msg}, + f"received message: {msg_for_log.__class__.__name__}", + extra={"protobuf": msg_for_log}, ) return msg