From e7e86c23c012f13441d0acf331aec6389595aeb8 Mon Sep 17 00:00:00 2001 From: DustInDark Date: Mon, 8 Nov 2021 23:51:01 +0900 Subject: [PATCH] Feature/output detect count151 (#167) * add output process count of detects events #151 * add output process count of detects event when output stdio #151 * add format enter --- src/afterfact.rs | 7 ++++++- src/detections/print.rs | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/afterfact.rs b/src/afterfact.rs index 393b3611..2dc3301d 100644 --- a/src/afterfact.rs +++ b/src/afterfact.rs @@ -73,7 +73,7 @@ pub fn after_fact() { fn emit_csv(writer: &mut W) -> Result<(), Box> { let mut wtr = csv::WriterBuilder::new().from_writer(writer); let messages = print::MESSAGES.lock().unwrap(); - + let mut detect_count = 0; for (time, detect_infos) in messages.iter() { for detect_info in detect_infos { wtr.serialize(CsvFormat { @@ -84,7 +84,12 @@ fn emit_csv(writer: &mut W) -> Result<(), Box> { message: &detect_info.detail, })?; } + detect_count += detect_infos.len(); } + println!(""); + println!("Events Detected:{:?}", detect_count); + println!(""); + wtr.flush()?; Ok(()) } diff --git a/src/detections/print.rs b/src/detections/print.rs index 228c9464..136ba368 100644 --- a/src/detections/print.rs +++ b/src/detections/print.rs @@ -131,11 +131,16 @@ impl Message { /// 最後に表示を行う pub fn print(&self) { + let mut detect_count = 0; for (key, detect_infos) in self.map.iter() { for detect_info in detect_infos.iter() { println!("{} <{}> {}", key, detect_info.title, detect_info.detail); } + detect_count += detect_infos.len(); } + println!(""); + println!("Events Detected:{:?}", detect_count); + println!(""); } pub fn iter(&self) -> &BTreeMap, Vec> {