Skip to content

Commit 6198556

Browse files
authored
Merge pull request #14 from uncenter/pr-b968e7a7
feat: overhaul logging
2 parents f27b763 + 0167dc4 commit 6198556

File tree

7 files changed

+277
-32
lines changed

7 files changed

+277
-32
lines changed

Cargo.lock

Lines changed: 213 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ zip = "0.6" # for file-zipping related things
2323
walkdir = "2"
2424
proc-macro2 = "1.0.46"
2525
yansi = "1.0.1"
26+
env_logger = "0.11.5"
27+
log = "0.4.22"

src/args.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,8 @@ pub struct CommandArgs {
2828
/// Download and zip directories
2929
#[arg(short, long = "zip")]
3030
pub zipped: bool,
31+
32+
/// Disable verbose logging
33+
#[arg(short, long)]
34+
pub quiet: bool,
3135
}

src/file_archiver.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl ZipArchiver {
5959
// Write file or directory explicitly
6060
// Some unzip tools unzip files with directory paths correctly, some do not!
6161
if entry_path.is_file() {
62-
println!("[+] Adding file {:?} as {:?} ...", entry_path, entry_name);
62+
log::info!("[+] Adding file {:?} as {:?}...", entry_path, entry_name);
6363
zip.start_file(entry_name, options)?;
6464
let mut fh = File::open(entry_path)?;
6565

@@ -69,7 +69,7 @@ impl ZipArchiver {
6969
} else if !entry_name.is_empty() {
7070
// Only if not root! Avoids path spec / warning
7171
// and mapname conversion failed error on unzip
72-
println!("[+] Adding dir {:?} as {:?} ...", entry_path, entry_name);
72+
log::info!("[+] Adding dir {:?} as {:?}...", entry_path, entry_name);
7373
zip.add_directory(entry_name, options)?;
7474
}
7575
}
@@ -103,7 +103,7 @@ impl ZipArchiver {
103103
file,
104104
)?;
105105

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

108108
Ok(())
109109
}

0 commit comments

Comments
 (0)