From cefad19a3a829d9bf2021ba109cef05e3bb15fb9 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Thu, 16 Nov 2023 18:28:20 -0700 Subject: [PATCH] reformat output to be nicer --- .../acars_connection_manager/src/message_handler.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/rust/libraries/acars_connection_manager/src/message_handler.rs b/rust/libraries/acars_connection_manager/src/message_handler.rs index f9116089..97d2b04e 100644 --- a/rust/libraries/acars_connection_manager/src/message_handler.rs +++ b/rust/libraries/acars_connection_manager/src/message_handler.rs @@ -322,16 +322,21 @@ pub async fn print_stats( loop { sleep(Duration::from_secs(stats_every)).await; let total_all_time_locked = *total_all_time.lock().await; - info!("{} in the last {} minute(s):\nTotal messages processed: {}\nTotal messages processed since last update: {}", - queue_type, stats_minutes, total_all_time_locked, total_since_last.lock().await); + let mut output: String = String::new(); + output.push_str(&format!( + "{} in the last {} minute(s):\nTotal messages processed: {}\nTotal messages processed since last update: {}\n", + queue_type, stats_minutes, total_all_time_locked, total_since_last.lock().await + )); *total_since_last.lock().await = 0; // now print the frequencies, and show each as a percentage of the total_all_time for freq in frequencies.lock().await.iter_mut() { let percentage: f64 = (freq.count as f64 / total_all_time_locked as f64) * 100.0; - info!("{}: {} ({:.2}%)", freq.freq, freq.count, percentage); + output.push_str(format!("{} {}: {}/{} ({:.2}%)\n", queue_type, freq.freq, freq.count, total_all_time_locked, percentage)); } + + println!("{}", output); } }