Skip to content

Commit

Permalink
Merge pull request #14 from uncenter/pr-b968e7a7
Browse files Browse the repository at this point in the history
feat: overhaul logging
  • Loading branch information
alok8bb authored Jul 28, 2024
2 parents f27b763 + 0167dc4 commit 6198556
Show file tree
Hide file tree
Showing 7 changed files with 277 additions and 32 deletions.
220 changes: 213 additions & 7 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ zip = "0.6" # for file-zipping related things
walkdir = "2"
proc-macro2 = "1.0.46"
yansi = "1.0.1"
env_logger = "0.11.5"
log = "0.4.22"
4 changes: 4 additions & 0 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,8 @@ pub struct CommandArgs {
/// Download and zip directories
#[arg(short, long = "zip")]
pub zipped: bool,

/// Disable verbose logging
#[arg(short, long)]
pub quiet: bool,
}
6 changes: 3 additions & 3 deletions src/file_archiver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl ZipArchiver {
// Write file or directory explicitly
// Some unzip tools unzip files with directory paths correctly, some do not!
if entry_path.is_file() {
println!("[+] Adding file {:?} as {:?} ...", entry_path, entry_name);
log::info!("[+] Adding file {:?} as {:?}...", entry_path, entry_name);
zip.start_file(entry_name, options)?;
let mut fh = File::open(entry_path)?;

Expand All @@ -69,7 +69,7 @@ impl ZipArchiver {
} else if !entry_name.is_empty() {
// Only if not root! Avoids path spec / warning
// and mapname conversion failed error on unzip
println!("[+] Adding dir {:?} as {:?} ...", entry_path, entry_name);
log::info!("[+] Adding dir {:?} as {:?}...", entry_path, entry_name);
zip.add_directory(entry_name, options)?;
}
}
Expand Down Expand Up @@ -103,7 +103,7 @@ impl ZipArchiver {
file,
)?;

println!("[+] Zip archived: {:?}", &self.m_dest_zip_fname);
log::info!("[+] Zip archived as {:?}.", &self.m_dest_zip_fname);

Ok(())
}
Expand Down
Loading

0 comments on commit 6198556

Please sign in to comment.