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:
+6
-1
@@ -73,7 +73,7 @@ pub fn after_fact() {
|
|||||||
fn emit_csv<W: std::io::Write>(writer: &mut W) -> Result<(), Box<dyn Error>> {
|
fn emit_csv<W: std::io::Write>(writer: &mut W) -> Result<(), Box<dyn Error>> {
|
||||||
let mut wtr = csv::WriterBuilder::new().from_writer(writer);
|
let mut wtr = csv::WriterBuilder::new().from_writer(writer);
|
||||||
let messages = print::MESSAGES.lock().unwrap();
|
let messages = print::MESSAGES.lock().unwrap();
|
||||||
|
let mut detect_count = 0;
|
||||||
for (time, detect_infos) in messages.iter() {
|
for (time, detect_infos) in messages.iter() {
|
||||||
for detect_info in detect_infos {
|
for detect_info in detect_infos {
|
||||||
wtr.serialize(CsvFormat {
|
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,
|
message: &detect_info.detail,
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
|
detect_count += detect_infos.len();
|
||||||
}
|
}
|
||||||
|
println!("");
|
||||||
|
println!("Events Detected:{:?}", detect_count);
|
||||||
|
println!("");
|
||||||
|
|
||||||
wtr.flush()?;
|
wtr.flush()?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -131,11 +131,16 @@ impl Message {
|
|||||||
|
|
||||||
/// 最後に表示を行う
|
/// 最後に表示を行う
|
||||||
pub fn print(&self) {
|
pub fn print(&self) {
|
||||||
|
let mut detect_count = 0;
|
||||||
for (key, detect_infos) in self.map.iter() {
|
for (key, detect_infos) in self.map.iter() {
|
||||||
for detect_info in detect_infos.iter() {
|
for detect_info in detect_infos.iter() {
|
||||||
println!("{} <{}> {}", key, detect_info.title, detect_info.detail);
|
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>> {
|
pub fn iter(&self) -> &BTreeMap<DateTime<Utc>, Vec<DetectInfo>> {
|
||||||
|
|||||||
Reference in New Issue
Block a user