From 18adbd1926ea9251b1c6dcf7fe9da1d6d4dca636 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Mon, 17 Jul 2017 15:30:29 -0400 Subject: [PATCH] Pretty plugin: only print negative timestamp warning once per component MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Mathieu Desnoyers Signed-off-by: Jérémie Galarneau --- plugins/text/pretty/pretty.h | 2 ++ plugins/text/pretty/print.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/text/pretty/pretty.h b/plugins/text/pretty/pretty.h index 272e06cf..554fc72f 100644 --- a/plugins/text/pretty/pretty.h +++ b/plugins/text/pretty/pretty.h @@ -92,6 +92,8 @@ struct pretty_component { uint64_t last_real_timestamp; uint64_t delta_real_timestamp; + + bool negative_timestamp_warning_done; }; enum stream_packet_context_quarks_enum { diff --git a/plugins/text/pretty/print.c b/plugins/text/pretty/print.c index e698f4bd..7cf9434d 100644 --- a/plugins/text/pretty/print.c +++ b/plugins/text/pretty/print.c @@ -191,9 +191,10 @@ void print_timestamp_wall(struct pretty_component *pretty, struct tm tm; time_t time_s = (time_t) ts_sec_abs; - if (is_negative) { + if (is_negative && !pretty->negative_timestamp_warning_done) { // TODO: log instead fprintf(stderr, "[warning] Fallback to [sec.ns] to print negative time value. Use --clock-seconds.\n"); + pretty->negative_timestamp_warning_done = true; goto seconds; } -- 2.34.1