From de301d4f22b8bb8d0356ecb8e37ecc939b3a91b8 Mon Sep 17 00:00:00 2001 From: Jan Starke Date: Mon, 29 Jul 2024 13:49:03 +0200 Subject: [PATCH] add error handling to evtxls --- src/bin/evtxls/main.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/bin/evtxls/main.rs b/src/bin/evtxls/main.rs index 9dfab95..cff5a7d 100644 --- a/src/bin/evtxls/main.rs +++ b/src/bin/evtxls/main.rs @@ -76,11 +76,18 @@ impl EvtxLs { }; let mut records = Vec::new(); + let mut handled_records = 0; + let mut expected_records: usize = 0; for result in parser.records_json_value() { + expected_records += 1; match result { - Err(_) => (), + Err(why) => { + log::error!("error while parsing a record; read {handled_records} until now. I'll try to continue with the next record"); + log::warn!("{why}") + } Ok(record) => { + handled_records += 1; if let Some(not_before) = self.cli.not_before.as_ref() { if &record.timestamp < not_before { continue; @@ -116,6 +123,10 @@ impl EvtxLs { } } + if handled_records < expected_records { + log::warn!("I expected {expected_records}, but only {handled_records} could be handled.") + } + Ok(records) }