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