698723
From 53673326ea78039b27e1dbd5328a8fe9a1a17445 Mon Sep 17 00:00:00 2001
698723
From: d032747 <michael.trapp@sap.com>
698723
Date: Tue, 15 Dec 2020 10:40:06 +0100
698723
Subject: [PATCH] busctl: add a timestamp to the output of the busctl monitor
698723
 command
698723
698723
(cherry picked from commit 6fe2a70b9160e35fdeed9d37bd31727c2d46a8b2)
698723
698723
Resolves: #1909214
698723
---
698723
 src/libsystemd/sd-bus/bus-dump.c | 11 +++++++++++
698723
 1 file changed, 11 insertions(+)
698723
698723
diff --git a/src/libsystemd/sd-bus/bus-dump.c b/src/libsystemd/sd-bus/bus-dump.c
698723
index 2bd06053a6..36f592e0ba 100644
698723
--- a/src/libsystemd/sd-bus/bus-dump.c
698723
+++ b/src/libsystemd/sd-bus/bus-dump.c
698723
@@ -55,6 +55,15 @@ int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags) {
698723
                 f = stdout;
698723
 
698723
         if (flags & BUS_MESSAGE_DUMP_WITH_HEADER) {
698723
+                char buf[FORMAT_TIMESTAMP_MAX];
698723
+                const char *p;
698723
+                usec_t ts = m->realtime;
698723
+
698723
+                if (ts == 0)
698723
+                        ts = now(CLOCK_REALTIME);
698723
+
698723
+                p = format_timestamp_us_utc(buf, sizeof(buf), ts);
698723
+
698723
                 fprintf(f,
698723
                         "%s%s%s Type=%s%s%s  Endian=%c  Flags=%u  Version=%u  Priority=%"PRIi64,
698723
                         m->header->type == SD_BUS_MESSAGE_METHOD_ERROR ? ansi_highlight_red() :
698723
@@ -82,6 +91,8 @@ int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags) {
698723
                 if (m->reply_cookie != 0)
698723
                         fprintf(f, "  ReplyCookie=%" PRIu64, m->reply_cookie);
698723
 
698723
+                fprintf(f, "  Timestamp=\"%s\"", strna(p));
698723
+
698723
                 fputs("\n", f);
698723
 
698723
                 if (m->sender)