summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authord032747 <michael.trapp@sap.com>2020-12-15 10:40:06 +0100
committerThe Plumber <50238977+systemd-rhel-bot@users.noreply.github.com>2021-06-22 14:32:34 +0200
commit53673326ea78039b27e1dbd5328a8fe9a1a17445 (patch)
tree436351aea0e001ed3f3cdcf5efa7cfcf5e660419
parent102f4ff97a24c2ddaf6e569c678a0a713f972863 (diff)
downloadsystemd-53673326ea78039b27e1dbd5328a8fe9a1a17445.tar.gz
busctl: add a timestamp to the output of the busctl monitor command
(cherry picked from commit 6fe2a70b9160e35fdeed9d37bd31727c2d46a8b2) Resolves: #1909214
-rw-r--r--src/libsystemd/sd-bus/bus-dump.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/libsystemd/sd-bus/bus-dump.c b/src/libsystemd/sd-bus/bus-dump.c
index 2bd06053a6..36f592e0ba 100644
--- a/src/libsystemd/sd-bus/bus-dump.c
+++ b/src/libsystemd/sd-bus/bus-dump.c
@@ -55,6 +55,15 @@ int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags) {
f = stdout;
if (flags & BUS_MESSAGE_DUMP_WITH_HEADER) {
+ char buf[FORMAT_TIMESTAMP_MAX];
+ const char *p;
+ usec_t ts = m->realtime;
+
+ if (ts == 0)
+ ts = now(CLOCK_REALTIME);
+
+ p = format_timestamp_us_utc(buf, sizeof(buf), ts);
+
fprintf(f,
"%s%s%s Type=%s%s%s Endian=%c Flags=%u Version=%u Priority=%"PRIi64,
m->header->type == SD_BUS_MESSAGE_METHOD_ERROR ? ansi_highlight_red() :
@@ -82,6 +91,8 @@ int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags) {
if (m->reply_cookie != 0)
fprintf(f, " ReplyCookie=%" PRIu64, m->reply_cookie);
+ fprintf(f, " Timestamp=\"%s\"", strna(p));
+
fputs("\n", f);
if (m->sender)