teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone

Blame SOURCES/0583-busctl-add-a-timestamp-to-the-output-of-the-busctl-m.patch

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