dbus-pcap: Add timestamp for regular output
json output remains without the timestamp for now.
Change-Id: I2c34356840d2bda8d6c70f4cbe9b7d95276859a1
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
diff --git a/amboar/obmc-scripts/dbus-pcap/dbus-pcap b/amboar/obmc-scripts/dbus-pcap/dbus-pcap
index 548468d..c6ed792 100755
--- a/amboar/obmc-scripts/dbus-pcap/dbus-pcap
+++ b/amboar/obmc-scripts/dbus-pcap/dbus-pcap
@@ -343,13 +343,13 @@
try:
cooked = parse_packet(packet)
if not matchers:
- yield cooked
+ yield packet.time, cooked
elif any(all(r(cooked) for r in m) for m in matchers):
if cooked.header.fixed.type == MessageType.METHOD_CALL.value:
s = [f for f in cooked.header.fields
if f.type == MessageFieldType.SENDER][0]
calls.add(CallEnvelope(cooked.header.fixed.cookie, s.data))
- yield cooked
+ yield packet.time, cooked
elif track_calls:
if cooked.header.fixed.type != MessageType.METHOD_RETURN.value:
continue
@@ -360,7 +360,7 @@
ce = CallEnvelope(rs.data, d.data)
if ce in calls:
calls.remove(ce)
- yield cooked
+ yield packet.time, cooked
except MalformedPacketError as e:
pass
@@ -424,11 +424,12 @@
matchers = parse_match_rules(args.expressions)
try:
if args.json:
- for msg in parse_session(stream, matchers, not args.no_track_calls):
- print(json.dumps(msg, default=packetconv))
+ for (_, msg) in parse_session(stream, matchers, not args.no_track_calls):
+ print("{}".format(json.dumps(msg, default=packetconv)))
else:
- for msg in parse_session(stream, matchers, not args.no_track_calls):
- print(msg)
+ for (time, msg) in parse_session(stream, matchers, not args.no_track_calls):
+ print("{}: {}".format(time, msg))
+ print()
except BrokenPipeError:
pass