- Commit
- 6751eb168376d233acf8d3a07e1744b487085b7d
- Parent
- 3fa87960576a314fee479a3e4b68699fba392d6b
- Author
- Pablo <pablo-pie@riseup.net>
- Date
Made the logging more concise
Made the logging of skipped entries more concise
Custum build of stapix for tikz.pablopie.xyz
Made the logging more concise
Made the logging of skipped entries more concise
2 files changed, 26 insertions, 12 deletions
| Status | Name | Changes | Insertions | Deletions |
| Modified | src/log.rs | 2 files changed | 24 | 10 |
| Modified | src/main.rs | 2 files changed | 2 | 2 |
diff --git a/src/log.rs b/src/log.rs @@ -25,8 +25,9 @@ pub(crate) enum Level { } pub struct JobListLogger { - total: usize, - count: usize, + total: usize, + count: usize, + skipped: usize, current_job_name: String, } @@ -94,10 +95,12 @@ pub fn usage_config() { impl JobListLogger { pub fn new(total_jobs: usize) -> Self { + const STRING_CAPACITY: usize = 64; Self { total: total_jobs, count: 0, - current_job_name: String::with_capacity(64) + skipped: 0, + current_job_name: String::with_capacity(STRING_CAPACITY), } } @@ -129,14 +132,11 @@ impl JobListLogger { self.job_finished_impl(); } - pub fn job_skipped(&mut self, job_name: &str) { - use crate::FULL_BUILD_OPT; + pub fn job_skipped(&mut self) { + self.count += 1; + self.skipped += 1; - self.inc_counter(job_name); - println!( - " {BOLD_YELLOW}Skipped{RESET} {name} (use {FULL_BUILD_OPT} to overwrite)", - name = self.current_job_name, - ); + if self.count == self.total { self.log_skipped(); } } fn inc_counter(&mut self, job_name: &str) { @@ -152,6 +152,20 @@ impl JobListLogger { name = self.current_job_name, empty = "", ); + + if self.count == self.total && self.skipped > 0 { self.log_skipped(); } + } + + fn log_skipped(&self) { + use crate::FULL_BUILD_OPT; + + print!(" {BOLD_YELLOW}Skipped{RESET} "); + if self.skipped == 1 { + print!("one entry. "); + } else { + print!("{} entries. ", self.skipped); + } + println!("Use {FULL_BUILD_OPT} to overwrite"); } }
diff --git a/src/main.rs b/src/main.rs @@ -161,7 +161,7 @@ fn render_gallery( let thumb_path: PathBuf = ThumbPath(pic).into(); if !full_build && !needs_rebuild(pic, &thumb_path) { - thumbs_logger.job_skipped(&pic.file_name); + thumbs_logger.job_skipped(); continue; } @@ -203,7 +203,7 @@ fn render_gallery( path.push(pic.file_name.clone() + ".html"); if !full_build && !needs_rebuild(&pic, &path) { - pages_logger.job_skipped(&pic.file_name); + pages_logger.job_skipped(); continue; }