|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
From c5af9aa2ccab078cf6f5bf68b88a3defa2f768f8 Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
Date: Sat, 13 May 2017 16:40:09 -0400
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
Subject: [PATCH] shared/logs-show: avoid printing "(null)" when timestamp is
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
not specified
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
$ perl -e 'print("MESSAGE\n", pack("q<", 1), "A\n\nMESSAGE=test2\n")' > message.bin
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
$ systemd-journal-remote -o /tmp/out.journal message.bin
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
$ journalctl -o export --file /tmp/out.journal
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
__CURSOR=s=b16c464c2db44384b29e75a564d8388e;i=1;b=6b0be47627bd4932913dc126012c21c0;m=0;t=0;x=b04263a253e357a
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
__REALTIME_TIMESTAMP=0
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
__MONOTONIC_TIMESTAMP=0
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
_BOOT_ID=6b0be47627bd4932913dc126012c21c0
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
MESSAGE=A
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
$ journalctl -o verbose --file /tmp/out.journal
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
(null) [s=b16c464c2db44384b29e75a564d8388e;i=1;b=6b0be47627bd4932913dc126012c21c0;m=0;t=0;x=b04263a253e357a]
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
MESSAGE=A
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
This is changed to
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
$ build/journalctl -o verbose --file /tmp/out.journal
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
(no timestamp) [s=b16c464c2db44384b29e75a564d8388e;i=1;b=6b0be47627bd4932913dc126012c21c0;m=0;t=0;x=b04263a253e357a]
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
MESSAGE=A
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
We should deal gracefully with unexpected input.
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
(cherry picked from commit 8924973ae2e1f0a0c131dcec0578669dc26e5e26)
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
---
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
src/shared/logs-show.c | 7 ++++---
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
1 file changed, 4 insertions(+), 3 deletions(-)
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
index 72c43e80cb..b4c72215c4 100644
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
--- a/src/shared/logs-show.c
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
+++ b/src/shared/logs-show.c
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
@@ -473,6 +473,7 @@ static int output_verbose(
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
_cleanup_free_ char *cursor = NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
uint64_t realtime = 0;
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
char ts[FORMAT_TIMESTAMP_MAX + 7];
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
+ const char *timestamp;
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
int r;
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
assert(f);
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
@@ -508,10 +509,10 @@ static int output_verbose(
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
return log_error_errno(r, "Failed to get cursor: %m");
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
+ timestamp = flags & OUTPUT_UTC ? format_timestamp_us_utc(ts, sizeof ts, realtime)
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
+ : format_timestamp_us(ts, sizeof ts, realtime);
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
fprintf(f, "%s [%s]\n",
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
- flags & OUTPUT_UTC ?
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
- format_timestamp_us_utc(ts, sizeof(ts), realtime) :
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
- format_timestamp_us(ts, sizeof(ts), realtime),
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
+ timestamp ?: "(no timestamp)",
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
cursor);
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
|
|
Zbigniew Jędrzejewski-Szmek |
f4a676 |
JOURNAL_FOREACH_DATA_RETVAL(j, data, length, r) {
|