From 34320a79819fceba1810067606990ab35bcf45b0 Mon Sep 17 00:00:00 2001 From: jtmoon79 <815261+jtmoon79@users.noreply.github.com> Date: Sun, 8 Jan 2023 01:31:46 -0800 Subject: [PATCH] src/ store path in Summary --- src/bin/bin.rs | 2 +- src/readers/summary.rs | 13 ++++++++----- src/readers/syslogprocessor.rs | 2 ++ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/bin/bin.rs b/src/bin/bin.rs index 4f5e9e98..a1b4a65a 100644 --- a/src/bin/bin.rs +++ b/src/bin/bin.rs @@ -1240,7 +1240,7 @@ fn exec_syslogprocessor_thread( // copied/cloned. Perhaps only save the `ErrorKind`? // Additionally, this thread should not print error messages, only the main thread should do that. // This needs more thought. - let summary = Summary::new_failed(filetype, blocksz, Some(err.to_string())); + let summary = Summary::new_failed(path.clone(), filetype, blocksz, Some(err.to_string())); let fileerr: FileProcessingResultBlockZero = match err.kind() { ErrorKind::PermissionDenied => { eprintln!("ERROR: {} for {:?}", err, path); diff --git a/src/readers/summary.rs b/src/readers/summary.rs index ef8c2083..3e16264a 100644 --- a/src/readers/summary.rs +++ b/src/readers/summary.rs @@ -4,7 +4,7 @@ #![allow(non_snake_case)] -use crate::common::{Count, FileMetadata, FileSz, FileType}; +use crate::common::{Count, FPath, FileSz, FileType}; use crate::data::datetime::{DateTimeLOpt, Year}; @@ -34,6 +34,8 @@ use std::fmt; /// For CLI option `--summary`. #[derive(Clone, Default)] pub struct Summary { + /// the `FileType` + pub path: FPath, /// the `FileType` pub filetype: FileType, /// `Count` of bytes stored by `BlockReader` @@ -140,6 +142,7 @@ impl Summary { /// Create a new `Summary` #[allow(clippy::too_many_arguments)] pub fn new( + path: FPath, filetype: FileType, BlockReader_bytes: Count, BlockReader_bytes_total: FileSz, @@ -197,14 +200,12 @@ impl Summary { debug_assert_ge!(BlockReader_blocksz, BLOCKSZ_MIN, "blocksz too small"); debug_assert_le!(BlockReader_blocksz, BLOCKSZ_MAX, "blocksz too big"); // XXX: in case of a file without datetime stamp year, syslines may be reprocessed. - // the count of syslines processed may reflect reprocoessing the same line in the file, + // the count of syslines processed may reflect reprocessing the same line in the file, // leading to a `SyslineReader_syslines` that is more than `LineReader_lines`. // See `syslogprocessor.process_missing_year()`. //debug_assert_ge!(LineReader_lines, SyslineReader_syslines, "There is less Lines than Syslines"); - if LineReader_lines < SyslineReader_syslines { - dp_wrn!("There is less Lines {} than Syslines {}", LineReader_lines, SyslineReader_syslines); - } Summary { + path, filetype, BlockReader_bytes, BlockReader_bytes_total, @@ -262,6 +263,7 @@ impl Summary { /// (e.g. PermissionDenied, etc.). #[allow(clippy::too_many_arguments)] pub fn new_failed( + path: FPath, filetype: FileType, BlockReader_blocksz: BlockSz, Error_: Option, @@ -271,6 +273,7 @@ impl Summary { debug_assert_le!(BlockReader_blocksz, BLOCKSZ_MAX, "blocksz too big"); Summary { + path, filetype, BlockReader_blocksz, Error_, diff --git a/src/readers/syslogprocessor.rs b/src/readers/syslogprocessor.rs index a50fe9a3..b7d1a45b 100644 --- a/src/readers/syslogprocessor.rs +++ b/src/readers/syslogprocessor.rs @@ -1081,6 +1081,7 @@ impl SyslogProcessor { /// /// [`Summary`]: crate::readers::summary::Summary pub fn summary(&self) -> Summary { + let path = self.path().clone(); let filetype = self.filetype(); let BlockReader_bytes = self .syslinereader @@ -1264,6 +1265,7 @@ impl SyslogProcessor { let Error_: Option = self.Error_.clone(); Summary::new( + path, filetype, BlockReader_bytes, BlockReader_bytes_total,