From d18a2614d86e374479f691aeee1c0091b1eee0ca Mon Sep 17 00:00:00 2001 From: Antoine Tenart Date: Wed, 26 Jun 2024 18:59:54 +0200 Subject: [PATCH] collect: format date in UTC if requested Signed-off-by: Antoine Tenart --- retis/src/collect/cli.rs | 3 +++ retis/src/collect/collector.rs | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/retis/src/collect/cli.rs b/retis/src/collect/cli.rs index 32e857b4d..8d73245f7 100644 --- a/retis/src/collect/cli.rs +++ b/retis/src/collect/cli.rs @@ -68,6 +68,9 @@ defaults to \"retis.data\"." #[arg(long, help = "Format used when printing an event.")] #[clap(value_enum, default_value_t=CliDisplayFormatFlavor::MultiLine)] pub(super) format: CliDisplayFormatFlavor, + #[arg(long, help = "Time format used when printing an event.")] + #[clap(value_enum, default_value_t=CliTimeFormat::MonotonicTimestamp)] + pub(super) time_format: CliTimeFormat, #[arg( id = "filter-packet", short, diff --git a/retis/src/collect/collector.rs b/retis/src/collect/collector.rs index 4aeef167c..f13f66aa9 100644 --- a/retis/src/collect/collector.rs +++ b/retis/src/collect/collector.rs @@ -421,9 +421,13 @@ impl Collectors { // Write events to stdout if we don't write to a file (--out) or if // explicitly asked to (--print). if collect.out.is_none() || collect.print { + let mut format = DisplayFormat::new(collect.format.into()); + format.set_time_format(collect.time_format.into()); + format.set_monotonic_offset(monotonic_clock_offset()?); + printers.push(PrintSingle::new( Box::new(io::stdout()), - PrintSingleFormat::Text(DisplayFormat::new(collect.format.into())), + PrintSingleFormat::Text(format), )); }