core: debug messages when reading from wire

fixes #373
pull/328/head
matejcik 5 years ago committed by matejcik
parent b9c978c1e2
commit cf70f82d90

@ -101,7 +101,7 @@ class Context:
if __debug__: if __debug__:
log.debug( log.debug(
__name__, "%s:%x read: %s", self.iface.iface_num(), self.sid, exptype __name__, "%s:%x expect: %s", self.iface.iface_num(), self.sid, exptype
) )
await reader.aopen() # wait for the message header await reader.aopen() # wait for the message header
@ -111,6 +111,11 @@ class Context:
if exptype is None or reader.type != exptype.MESSAGE_WIRE_TYPE: if exptype is None or reader.type != exptype.MESSAGE_WIRE_TYPE:
raise UnexpectedMessageError(reader) raise UnexpectedMessageError(reader)
if __debug__:
log.debug(
__name__, "%s:%x read: %s", self.iface.iface_num(), self.sid, exptype
)
# parse the message and return it # parse the message and return it
return await protobuf.load_message(reader, exptype) return await protobuf.load_message(reader, exptype)
@ -120,7 +125,7 @@ class Context:
if __debug__: if __debug__:
log.debug( log.debug(
__name__, __name__,
"%s:%x read: %s", "%s:%x expect: %s",
self.iface.iface_num(), self.iface.iface_num(),
self.sid, self.sid,
allowed_types, allowed_types,
@ -136,6 +141,11 @@ class Context:
# find the protobuf type # find the protobuf type
exptype = messages.get_type(reader.type) exptype = messages.get_type(reader.type)
if __debug__:
log.debug(
__name__, "%s:%x read: %s", self.iface.iface_num(), self.sid, exptype
)
# parse the message and return it # parse the message and return it
return await protobuf.load_message(reader, exptype) return await protobuf.load_message(reader, exptype)
@ -223,6 +233,10 @@ async def protobuf_workflow(
from trezor.messages.Failure import Failure from trezor.messages.Failure import Failure
req = await protobuf.load_message(reader, messages.get_type(reader.type)) req = await protobuf.load_message(reader, messages.get_type(reader.type))
if __debug__:
log.debug(__name__, "%s:%x request: %s", ctx.iface.iface_num(), ctx.sid, req)
try: try:
res = await handler(ctx, req, *args) res = await handler(ctx, req, *args)
except UnexpectedMessageError: except UnexpectedMessageError:

Loading…
Cancel
Save