OSDN Git Service

blueberry: print Data as hex, to make matching to wireshark easier
authorZach Johnson <zachoverflow@google.com>
Sun, 7 Feb 2021 19:22:05 +0000 (11:22 -0800)
committerZach Johnson <zachoverflow@google.com>
Mon, 8 Feb 2021 06:19:27 +0000 (22:19 -0800)
Bug: 171749953
Tag: #gd-refactor
Test: gd/cert/run --rhost
Change-Id: I25b03d896157451253e2e54bd9c1ee3d23a90286

gd/cert/logging_client_interceptor.py

index ec10cde..b74cdfc 100644 (file)
 import grpc
 import re
 
+from facade import common_pb2 as common
 from google.protobuf import text_format
 
 
+def custom_message_formatter(m, ident, as_one_line):
+    if m.DESCRIPTOR == common.Data.DESCRIPTOR:
+        return 'payload: (hex) "{}"'.format(m.payload.hex())
+    return None
+
+
 def pretty_print(request):
-    return '{} {}'.format(type(request).__name__, text_format.MessageToString(request, as_one_line=True))
+    return '{} {}'.format(
+        type(request).__name__,
+        text_format.MessageToString(request, as_one_line=True, message_formatter=custom_message_formatter))
 
 
 class LoggingRandezvousWrapper():