Refactoring to use appropriate log level for debug logs

This commit is contained in:
DoumanAsh 2023-03-29 20:11:19 +09:00 committed by Josh Holmer
parent 5341de2163
commit 3b086c34f1

View file

@ -466,13 +466,13 @@ fn optimize_png(
// Print png info // Print png info
let file_original_size = original_data.len(); let file_original_size = original_data.len();
let idat_original_size = png.idat_data.len(); let idat_original_size = png.idat_data.len();
info!( debug!(
" {}x{} pixels, PNG format", " {}x{} pixels, PNG format",
png.raw.ihdr.width, png.raw.ihdr.height png.raw.ihdr.width, png.raw.ihdr.height
); );
report_format(" ", &png.raw); report_format(" ", &png.raw);
info!(" IDAT size = {} bytes", idat_original_size); debug!(" IDAT size = {} bytes", idat_original_size);
info!(" File size = {} bytes", file_original_size); debug!(" File size = {} bytes", file_original_size);
// Do this first so that reductions can ignore certain chunks such as bKGD // Do this first so that reductions can ignore certain chunks such as bKGD
perform_strip(png, opts); perform_strip(png, opts);
@ -560,7 +560,7 @@ fn optimize_png(
None None
} }
} else { } else {
info!("Trying: {}", trial.filter); debug!("Trying: {}", trial.filter);
let original_len = idat_original_size; let original_len = idat_original_size;
let best_size = AtomicMin::new(if opts.force { None } else { Some(original_len) }); let best_size = AtomicMin::new(if opts.force { None } else { Some(original_len) });
perform_trial(&png.filtered, opts, trial, &best_size) perform_trial(&png.filtered, opts, trial, &best_size)
@ -591,7 +591,7 @@ fn optimize_png(
}); });
} }
info!("Trying: {} filters", results.len()); debug!("Trying: {} filters", results.len());
let original_len = idat_original_size; let original_len = idat_original_size;
let best_size = AtomicMin::new(if opts.force { None } else { Some(original_len) }); let best_size = AtomicMin::new(if opts.force { None } else { Some(original_len) });
@ -614,8 +614,8 @@ fn optimize_png(
if let Some((opts, idat_data)) = best { if let Some((opts, idat_data)) = best {
png.idat_data = idat_data; png.idat_data = idat_data;
info!("Found better combination:"); debug!("Found better combination:");
info!( debug!(
" zc = {} f = {} {} bytes", " zc = {} f = {} {} bytes",
opts.compression, opts.compression,
opts.filter, opts.filter,
@ -631,27 +631,27 @@ fn optimize_png(
let output = png.output(); let output = png.output();
if idat_original_size >= png.idat_data.len() { if idat_original_size >= png.idat_data.len() {
info!( debug!(
" IDAT size = {} bytes ({} bytes decrease)", " IDAT size = {} bytes ({} bytes decrease)",
png.idat_data.len(), png.idat_data.len(),
idat_original_size - png.idat_data.len() idat_original_size - png.idat_data.len()
); );
} else { } else {
info!( debug!(
" IDAT size = {} bytes ({} bytes increase)", " IDAT size = {} bytes ({} bytes increase)",
png.idat_data.len(), png.idat_data.len(),
png.idat_data.len() - idat_original_size png.idat_data.len() - idat_original_size
); );
} }
if file_original_size >= output.len() { if file_original_size >= output.len() {
info!( debug!(
" file size = {} bytes ({} bytes = {:.2}% decrease)", " file size = {} bytes ({} bytes = {:.2}% decrease)",
output.len(), output.len(),
file_original_size - output.len(), file_original_size - output.len(),
(file_original_size - output.len()) as f64 / file_original_size as f64 * 100_f64 (file_original_size - output.len()) as f64 / file_original_size as f64 * 100_f64
); );
} else { } else {
info!( debug!(
" file size = {} bytes ({} bytes = {:.2}% increase)", " file size = {} bytes ({} bytes = {:.2}% increase)",
output.len(), output.len(),
output.len() - file_original_size, output.len() - file_original_size,
@ -815,7 +815,7 @@ impl Deadline {
/// Display the format of the image data /// Display the format of the image data
fn report_format(prefix: &str, png: &PngImage) { fn report_format(prefix: &str, png: &PngImage) {
if let Some(ref palette) = png.palette { if let Some(ref palette) = png.palette {
info!( debug!(
"{}{} bits/pixel, {} colors in palette ({})", "{}{} bits/pixel, {} colors in palette ({})",
prefix, prefix,
png.ihdr.bit_depth, png.ihdr.bit_depth,
@ -823,7 +823,7 @@ fn report_format(prefix: &str, png: &PngImage) {
png.ihdr.interlaced png.ihdr.interlaced
); );
} else { } else {
info!( debug!(
"{}{}x{} bits/pixel, {} ({})", "{}{}x{} bits/pixel, {} ({})",
prefix, prefix,
png.channels_per_pixel(), png.channels_per_pixel(),