Skip to content

Commit

Permalink
src/ store path in Summary
Browse files Browse the repository at this point in the history
  • Loading branch information
jtmoon79 committed Jan 8, 2023
1 parent 133cb5c commit 34320a7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/bin/bin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
13 changes: 8 additions & 5 deletions src/readers/summary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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`
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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<String>,
Expand All @@ -271,6 +273,7 @@ impl Summary {
debug_assert_le!(BlockReader_blocksz, BLOCKSZ_MAX, "blocksz too big");

Summary {
path,
filetype,
BlockReader_blocksz,
Error_,
Expand Down
2 changes: 2 additions & 0 deletions src/readers/syslogprocessor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1264,6 +1265,7 @@ impl SyslogProcessor {
let Error_: Option<String> = self.Error_.clone();

Summary::new(
path,
filetype,
BlockReader_bytes,
BlockReader_bytes_total,
Expand Down

0 comments on commit 34320a7

Please sign in to comment.