Skip to content

Commit

Permalink
Cleanup cli output some more.
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Regali committed Jan 19, 2023
1 parent a5b3ffb commit 74be34a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/csv/tokenizer/guess_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use itertools::Itertools;
use regex::Regex;
use std::collections::HashMap;
use std::io::{BufRead, BufReader, Read, Seek};
use tracing::{debug, info, warn};
use tracing::{debug, warn};

fn guess_format_from_line(
line: &str,
Expand Down Expand Up @@ -101,7 +101,7 @@ pub(crate) fn guess_format_from_reader<R: Read + Seek>(
field_delimiter: format.0,
decimal_separator: format.1,
};
info!(
debug!(
"Inferring of csv delimiters resulted in decimal separators: '{:?}', field delimiter: '{:?}'",
delim.decimal_separator, delim.field_delimiter
);
Expand Down
13 changes: 4 additions & 9 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,17 +157,12 @@ fn process_file(
actual: impl AsRef<Path>,
rule: &Rule,
) -> Result<FileCompareResult, Box<dyn std::error::Error>> {
let file_name_nominal = get_file_name(nominal.as_ref()).ok_or(Error::FilePathParsingFails(
nominal.as_ref().to_string_lossy().into_owned(),
))?;
let file_name_actual = get_file_name(nominal.as_ref()).ok_or(Error::FilePathParsingFails(
actual.as_ref().to_string_lossy().into_owned(),
))?;
let file_name_nominal = nominal.as_ref().to_string_lossy();
let file_name_actual = actual.as_ref().to_string_lossy();
let _file_span = span!(tracing::Level::INFO, "Processing");
let _file_span = _file_span.enter();

info!("Nominal: {}", file_name_nominal);
info!("Actual: {}", file_name_actual);
info!("File: {file_name_nominal} | {file_name_actual}");

let compare_result: Result<FileCompareResult, Box<dyn std::error::Error>> =
match &rule.file_type {
Expand Down Expand Up @@ -197,7 +192,7 @@ fn process_file(
if compare_result.is_error {
error!("Files didn't match");
} else {
info!("Files matched");
debug!("Files matched");
}
} else {
error!("Problem comparing the files");
Expand Down
18 changes: 10 additions & 8 deletions src/report/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::fs::File;
use std::path::{Path, PathBuf};
use tera::{Context, Tera};
use thiserror::Error;
use tracing::{debug, info};
use tracing::{debug, info, span};
use vg_errortools::{fat_io_wrap_std, FatIOError};

#[derive(Error, Debug)]
Expand Down Expand Up @@ -123,7 +123,7 @@ pub fn write_html_detail(

let file = fat_io_wrap_std(&detail_file, &File::create)?;

info!("detail html {:?} created", &detail_file);
debug!("detail html {:?} created", &detail_file);

tera.render_to(&detail_file.to_string_lossy(), &ctx, file)?;

Expand Down Expand Up @@ -258,7 +258,7 @@ pub(crate) fn write_csv_detail(
ctx.insert("row_index_increment", &row_index_increment);

let file = fat_io_wrap_std(&detail_file, &File::create)?;
info!("detail html {:?} created", &detail_file);
debug!("detail html {:?} created", &detail_file);

tera.render_to(&detail_file.to_string_lossy(), &ctx, file)?;

Expand Down Expand Up @@ -318,7 +318,7 @@ pub fn write_image_detail(
ctx.insert("nominal_image", &nominal_image);

let file = fat_io_wrap_std(&detail_file, &File::create)?;
info!("detail html {:?} created", &detail_file);
debug!("detail html {:?} created", &detail_file);

tera.render_to(&detail_file.to_string_lossy(), &ctx, file)?;

Expand Down Expand Up @@ -395,7 +395,7 @@ pub fn write_pdf_detail(

ctx.insert("errors", diffs);
let file = fat_io_wrap_std(&detail_file, &File::create)?;
info!("detail html {:?} created", &detail_file);
debug!("detail html {:?} created", &detail_file);

tera.render_to(&detail_file.to_string_lossy(), &ctx, file)?;

Expand All @@ -409,6 +409,8 @@ pub(crate) fn create(
rule_results: &[RuleResult],
report_path: impl AsRef<Path>,
) -> Result<(), Error> {
let _reporting_span = span!(tracing::Level::INFO, "Reporting");
let _reporting_span = _reporting_span.enter();
let report_dir = report_path.as_ref();
if report_dir.is_dir() {
info!("Delete report folder");
Expand All @@ -421,12 +423,12 @@ pub(crate) fn create(
//move folders
for rule_result in rule_results.iter() {
let sub_folder = report_dir.join(&rule_result.rule.name);
info!("Create subfolder {:?}", &sub_folder);
debug!("Create subfolder {:?}", &sub_folder);
fat_io_wrap_std(&sub_folder, &fs::create_dir)?;
for file_result in rule_result.compare_results.iter() {
if let Some(detail) = &file_result.detail_path {
let target = &sub_folder.join(detail);
info!("moving subfolder {:?} to {:?}", &detail, &target);
debug!("moving subfolder {:?} to {:?}", &detail, &target);

let files = crate::glob_files(detail, &["*"])?;
for file in files.iter() {
Expand Down Expand Up @@ -469,6 +471,6 @@ pub(crate) fn write_index(
let file = fat_io_wrap_std(&index_file, &File::create)?;
tera.render_to(&index_file.to_string_lossy(), &ctx, file)?;

info!("Report.html created");
debug!("Report.html created");
Ok(())
}

0 comments on commit 74be34a

Please sign in to comment.