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
This commit is contained in:
DustInDark
2021-11-08 23:51:01 +09:00
committed by GitHub
parent 696dd9192a
commit e7e86c23c0
2 changed files with 11 additions and 1 deletions

View File

@@ -73,7 +73,7 @@ pub fn after_fact() {
fn emit_csv<W: std::io::Write>(writer: &mut W) -> Result<(), Box<dyn Error>> {
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<W: std::io::Write>(writer: &mut W) -> Result<(), Box<dyn Error>> {
message: &detect_info.detail,
})?;
}
detect_count += detect_infos.len();
}
println!("");
println!("Events Detected:{:?}", detect_count);
println!("");
wtr.flush()?;
Ok(())
}

View File

@@ -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<DateTime<Utc>, Vec<DetectInfo>> {