Skip to content

Commit

Permalink
Merge pull request #3 from obvMellow/v0.2.1
Browse files Browse the repository at this point in the history
Slight improvement in logging errors to file
  • Loading branch information
obvMellow authored Aug 14, 2024
2 parents 73b4a8d + 7a0538b commit 3637a3e
Show file tree
Hide file tree
Showing 3 changed files with 166 additions and 3 deletions.
154 changes: 153 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ tokio = { version = "1.39.2", features = ["rt-multi-thread"] }
sha2 = "0.10.8"
env_logger = "0.11.5"
rusqlite = { version = "0.32.1", features = ["bundled"] }
chrono = "0.4.38"
14 changes: 12 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,10 +416,20 @@ fn _copy(conn: &Transaction, is_multithread: bool, source_str: PathBuf, dest_str
);

if conclusion.error_list.len() > 0 {
let mut log_file = File::create("hardcpy.log").unwrap();
let log_folder = dirs::config_dir()
.unwrap_or(std::env::current_dir().unwrap())
.join("hardcpy/logs");
fs::create_dir_all(&log_folder).unwrap();

let path = log_folder.join(chrono::Local::now().to_rfc2822());
let mut log_file = File::create(&path).unwrap();
for err in conclusion.error_list {
log_file.write_all(err.as_ref()).unwrap();
log_file
.write_all(err.replace(" Skipping", "").as_ref())
.unwrap();
}

error!("Errors were written to \"{}\"", path.display().to_string());
}
false
}
Expand Down

0 comments on commit 3637a3e

Please sign in to comment.