Skip to content

Commit

Permalink
zune: Lower logs verbosity
Browse files Browse the repository at this point in the history
Replace `info!` with `trace!` for all decoders to reduce log verbosity for the library that may depend on the decoder.

Addresses #131 (comment)

Signed-off-by: caleb <etemesicaleb@gmail.com>
  • Loading branch information
etemesi254 committed Aug 15, 2023
1 parent c889e88 commit 9e56b06
Show file tree
Hide file tree
Showing 12 changed files with 77 additions and 77 deletions.
19 changes: 10 additions & 9 deletions crates/zune-bmp/src/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use alloc::vec::Vec;
use alloc::{format, vec};

use log::{info, warn};
use log::{trace, warn};
use zune_core::bit_depth::BitDepth;
use zune_core::bytestream::{ZByteReader, ZReaderTrait};
use zune_core::colorspace::ColorSpace;
Expand Down Expand Up @@ -182,8 +182,8 @@ where
));
}

info!("Width: {}", self.width);
info!("Height: {}", self.height);
trace!("Width: {}", self.width);
trace!("Height: {}", self.height);

// planes
if self.bytes.get_u16_le() != 1 {
Expand Down Expand Up @@ -308,9 +308,9 @@ where
self.palette_numbers = colors as usize;
}

info!("Pixel format : {:?}", self.pix_fmt);
info!("Compression : {:?}", compression);

trace!("Pixel format : {:?}", self.pix_fmt);
trace!("Compression : {:?}", compression);
trace!("Bit depth: {:?}", depth);
self.comp = compression;
self.depth = depth;
self.ihszie = ihsize;
Expand Down Expand Up @@ -684,11 +684,13 @@ where
//
//
// Code is from ffmpeg

// Allocate space for our RLE storage
let mut buf = vec![0; self.width * self.height * usize::from(self.depth >> 3)];
//let rt = temp_scanline.len();
let mut line = (self.height - 1) as i32;
let mut pos = 0;
let (mut p1, mut p2) = (0, 0);
let (mut p1, mut p2);
// loop until no more bytes are left
while !self.bytes.eof() {
p1 = self.bytes.get_u8();
Expand Down Expand Up @@ -819,10 +821,9 @@ where
_ => unreachable!("Uhh ohh")
}
}
let t = 0;
}
warn!("RLE warning, no end of picture code");
return Ok(buf);
Ok(buf)
}
}

Expand Down
11 changes: 5 additions & 6 deletions crates/zune-bmp/tests/test_palette.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ fn decode(file: &String) -> Vec<u8> {
// let _ = decode(&path);
// }
//
// #[test]
// fn decode_palette_1bpp()
// {
// let path = "/home/caleb/Documents/zune-image/test-images/bmp/rgb16.bmp".to_string();
// let _ = decode(&path);
// }
#[test]
fn decode_palette_1bpp() {
let path = "/home/caleb/Documents/zune-image/test-images/bmp/rgb24.bmp".to_string();
let _ = decode(&path);
}
7 changes: 4 additions & 3 deletions crates/zune-farbfeld/src/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
use alloc::vec;
use alloc::vec::Vec;

use log::info;
use log::trace;

use zune_core::bit_depth::BitDepth;
use zune_core::bytestream::{ZByteReader, ZReaderTrait};
use zune_core::colorspace::ColorSpace;
Expand Down Expand Up @@ -69,8 +70,8 @@ where
// 32 BE height
self.height = self.stream.get_u32_be() as usize;

info!("Image width: {}", self.width);
info!("Image height: {}", self.height);
trace!("Image width: {}", self.width);
trace!("Image height: {}", self.height);

if self.height > self.options.get_max_height() {
return Err("Image Height is greater than max height. Bump up max_height to support such images");
Expand Down
6 changes: 3 additions & 3 deletions crates/zune-hdr/src/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use core::iter::Iterator;
use core::option::Option::{self, *};
use core::result::Result::{self, *};

use log::{info, trace};
use log::trace;
use zune_core::bytestream::{ZByteReader, ZReaderTrait};
use zune_core::colorspace::ColorSpace;
use zune_core::options::DecoderOptions;
Expand Down Expand Up @@ -204,8 +204,8 @@ where
));
}

info!("Width: {}", self.width);
info!("Height: {}", self.height);
trace!("Width: {}", self.width);
trace!("Height: {}", self.height);

self.decoded_headers = true;

Expand Down
8 changes: 4 additions & 4 deletions crates/zune-image/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This software is free software; You can redistribute it or modify it under terms of the MIT, Apache License or Zlib license
*/

use log::info;
use log::trace;
use zune_core::bit_depth::{BitDepth, BitType};
use zune_core::colorspace::{ColorSpace, ALL_COLORSPACES};
use zune_core::options::EncoderOptions;
Expand Down Expand Up @@ -284,7 +284,7 @@ pub trait EncoderTrait {
let default_colorspace = self.default_colorspace(colorspace);
let image_format = self.format();

info!("Image is in {colorspace:?} colorspace,converting it to {default_colorspace:?} which is the default configured colorspace of {image_format:?}");
trace!("Image is in {colorspace:?} colorspace,converting it to {default_colorspace:?} which is the default configured colorspace of {image_format:?}");
// try converting it to a supported colorspace
let converter = ColorspaceConv::new(default_colorspace);

Expand All @@ -293,13 +293,13 @@ pub trait EncoderTrait {
let image_depth = image.get_depth();

if !self.supported_bit_depth().contains(&depth) {
info!(
trace!(
"Image depth is in {:?}, but {} encoder supports {:?}",
image.get_depth(),
self.get_name(),
self.supported_bit_depth()
);
info!(
trace!(
"Converting image to a depth of {:?}",
self.default_depth(image_depth)
);
Expand Down
30 changes: 15 additions & 15 deletions crates/zune-image/src/workflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

use std::time::Instant;

use log::Level::Info;
use log::{info, log_enabled, Level};
use log::Level::Trace;
use log::{log_enabled, trace, Level};

use crate::codecs::ImageFormat;
use crate::errors::ImageErrors;
Expand Down Expand Up @@ -178,7 +178,7 @@ where
if self.decode.is_none() {
// we have an image, no need to decode a new one
if self.image.is_empty() {
info!("Image already present, no need to decode");
trace!("Image already present, no need to decode");
// move to the next state
self.state = state.next();

Expand All @@ -187,9 +187,9 @@ where
return Err(ImageErrors::NoImageForOperations);
}

if log_enabled!(Info) {
if log_enabled!(Trace) {
println!();
info!("Current state: {:?}\n", state);
trace!("Current state: {:?}\n", state);
}

let decode_op = self.decode.take().unwrap();
Expand All @@ -202,31 +202,31 @@ where

self.state = state.next();

info!("Finished decoding in {} ms", (stop - start).as_millis());
trace!("Finished decoding in {} ms", (stop - start).as_millis());
}
WorkFlowState::Operations => {
if self.image.is_empty() {
return Err(ImageErrors::NoImageForOperations);
}

if log_enabled!(Info) && !self.operations.is_empty() {
if log_enabled!(Trace) && !self.operations.is_empty() {
println!();
info!("Current state: {:?}\n", state);
trace!("Current state: {:?}\n", state);
}

for image in self.image.iter_mut() {
for operation in &self.operations {
let operation_name = operation.get_name();

info!("Running {}", operation_name);
trace!("Running {}", operation_name);

let start = Instant::now();

operation.execute(image)?;

let stop = Instant::now();

info!(
trace!(
"Finished running `{operation_name}` in {} ms",
(stop - start).as_millis()
);
Expand All @@ -239,24 +239,24 @@ where
return Err(ImageErrors::NoImageForOperations);
}

if log_enabled!(Info) && !self.encode.is_empty() {
if log_enabled!(Trace) && !self.encode.is_empty() {
println!();
info!("Current state: {:?}\n", state);
trace!("Current state: {:?}\n", state);
}

for image in self.image.iter() {
for encoder in self.encode.iter_mut() {
let encoder_name = encoder.get_name();

info!("Running {}", encoder_name);
trace!("Running {}", encoder_name);

let start = Instant::now();

let result = encoder.encode_to_result(image)?;
self.encode_result.push(result);
let stop = Instant::now();

info!(
trace!(
"Finished running `{encoder_name}` in {} ms",
(stop - start).as_millis()
);
Expand All @@ -269,7 +269,7 @@ where
self.state = state.next();
}
WorkFlowState::Finished => {
info!("Finished operations for this workflow");
trace!("Finished operations for this workflow");

self.state = state.next();
return Ok(());
Expand Down
16 changes: 8 additions & 8 deletions crates/zune-jpegxl/src/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use std::marker::PhantomData;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::{Arc, Mutex};

use log::{info, log_enabled, Level};
use log::{log_enabled, trace, Level};
use zune_core::bit_depth::BitDepth;
use zune_core::options::EncoderOptions;

Expand Down Expand Up @@ -1067,14 +1067,14 @@ impl<'a> JxlSimpleEncoder<'a> {
return Err(JxlEncodeErrors::ZeroDimension("height"));
}

if log_enabled!(Level::Info) {
if log_enabled!(Level::Trace) {
println!();
info!("JXL details");
info!("Width: {}", width);
info!("Height: {}", height);
info!("Colorspace: {:?}", colorspace);
info!("Depth: {:?}", depth);
info!("Configured threads: {:?}", self.options.get_num_threads());
trace!("JXL details");
trace!("Width: {}", width);
trace!("Height: {}", height);
trace!("Colorspace: {:?}", colorspace);
trace!("Depth: {:?}", depth);
trace!("Configured threads: {:?}", self.options.get_num_threads());
println!();
}

Expand Down
7 changes: 3 additions & 4 deletions crates/zune-png/src/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use alloc::vec::Vec;
use alloc::{format, vec};
use core::cmp::min;

use log::info;
use log::trace;
use zune_core::bit_depth::{BitDepth, ByteEndian};
use zune_core::bytestream::{ZByteReader, ZReaderTrait};
use zune_core::colorspace::ColorSpace;
Expand Down Expand Up @@ -573,9 +573,8 @@ impl<T: ZReaderTrait> PngDecoder<T> {
self.decode_headers()?;
}

info!("Input Colorspace: {:?} ", self.png_info.color);

info!("Output Colorspace: {:?} ", self.get_colorspace().unwrap());
trace!("Input Colorspace: {:?} ", self.png_info.color);
trace!("Output Colorspace: {:?} ", self.get_colorspace().unwrap());

if self.frames.get(self.current_frame).is_none() {
return Err(PngDecodeErrors::GenericStatic("No more frames"));
Expand Down
12 changes: 6 additions & 6 deletions crates/zune-png/src/headers/readers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use alloc::{format, vec};

use log::{info, warn};
use log::{trace, warn};
use zune_core::bytestream::ZReaderTrait;
use zune_inflate::DeflateDecoder;

Expand Down Expand Up @@ -113,11 +113,11 @@ impl<T: ZReaderTrait> PngDecoder<T> {
// skip crc
self.stream.skip(4);

info!("Width: {}", self.png_info.width);
info!("Height: {}", self.png_info.height);
info!("Filter type:{:?}", self.png_info.filter_method);
info!("Depth: {:?}", self.png_info.depth);
info!("Interlace :{:?}", self.png_info.interlace_method);
trace!("Width: {}", self.png_info.width);
trace!("Height: {}", self.png_info.height);
trace!("Filter type:{:?}", self.png_info.filter_method);
trace!("Depth: {:?}", self.png_info.depth);
trace!("Interlace :{:?}", self.png_info.interlace_method);

self.seen_hdr = true;

Expand Down
18 changes: 9 additions & 9 deletions crates/zune-ppm/src/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use alloc::vec::Vec;
use alloc::{format, vec};
use core::fmt::{Debug, Formatter};

use log::info;
use log::trace;
use zune_core::bit_depth::{BitDepth, BitType, ByteEndian};
use zune_core::bytestream::{ZByteReader, ZReaderTrait};
use zune_core::colorspace::ColorSpace;
Expand Down Expand Up @@ -193,7 +193,7 @@ where
return Err(PPMDecodeErrors::Generic(msg));
}

info!("Width: {}, height: {}", self.width, self.height);
trace!("Width: {}, height: {}", self.width, self.height);

skip_spaces(&mut self.reader);

Expand Down Expand Up @@ -344,10 +344,10 @@ where

self.decoded_headers = true;

info!("Width: {}", self.width);
info!("Height: {}", self.height);
info!("Colorspace: {:?}", self.colorspace);
info!("Depth: {:?}", self.bit_depth);
trace!("Width: {}", self.width);
trace!("Height: {}", self.height);
trace!("Colorspace: {:?}", self.colorspace);
trace!("Depth: {:?}", self.bit_depth);

Ok(())
}
Expand All @@ -358,7 +358,7 @@ where
b'6' => ColorSpace::RGB,
_ => unreachable!()
};
info!("Colorspace: {:?}", colorspace);
trace!("Colorspace: {:?}", colorspace);

self.colorspace = colorspace;

Expand Down Expand Up @@ -389,7 +389,7 @@ where
return Err(PPMDecodeErrors::Generic(msg));
}

info!("Width: {}, height: {}", self.width, self.height);
trace!("Width: {}, height: {}", self.width, self.height);

skip_spaces(&mut self.reader);
// read max value
Expand All @@ -408,7 +408,7 @@ where
self.bit_depth = BitDepth::Sixteen;
}

info!("Bit Depth: {:?}", self.bit_depth);
trace!("Bit Depth: {:?}", self.bit_depth);
self.decoded_headers = true;

Ok(())
Expand Down
Loading

0 comments on commit 9e56b06

Please sign in to comment.