Skip to content

Commit

Permalink
Use kilobytes instead of bytes in trace for improved readability
Browse files Browse the repository at this point in the history
  • Loading branch information
filiptibell committed Mar 28, 2024
1 parent 353b75a commit 6baeefb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/sources/decompression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::result::RokitResult;

pub async fn decompress_gzip(gz_contents: impl AsRef<[u8]>) -> RokitResult<Vec<u8>> {
let gz_contents = gz_contents.as_ref().to_vec();
let num_bytes = gz_contents.len();
let num_kilobytes = gz_contents.len() / 1024;
let start = Instant::now();

// Decompressing gzip is a potentially expensive operation, so
Expand All @@ -18,7 +18,7 @@ pub async fn decompress_gzip(gz_contents: impl AsRef<[u8]>) -> RokitResult<Vec<u
decoder.read_to_end(&mut contents)?;

tracing::debug!(
num_bytes,
num_kilobytes,
elapsed = ?start.elapsed(),
"decompressed gzip"
);
Expand Down
8 changes: 4 additions & 4 deletions lib/sources/extraction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ pub async fn extract_zip_file(
let desired_file_path = PathBuf::from(&desired_file_name);

let zip_contents = zip_contents.as_ref().to_vec();
let num_bytes = zip_contents.len();
let num_kilobytes = zip_contents.len() / 1024;
let start = Instant::now();

// Reading a zip file is a potentially expensive operation, so
Expand Down Expand Up @@ -140,7 +140,7 @@ pub async fn extract_zip_file(
}

tracing::debug!(
num_bytes,
num_kilobytes,
elapsed = ?start.elapsed(),
found = found.is_some(),
"extracted zip file"
Expand All @@ -163,7 +163,7 @@ pub async fn extract_tar_file(
let desired_file_path = PathBuf::from(&desired_file_name);

let tar_contents = tar_contents.as_ref().to_vec();
let num_bytes = tar_contents.len();
let num_kilobytes = tar_contents.len() / 1024;
let start = Instant::now();

// Reading a tar file is a potentially expensive operation, so
Expand Down Expand Up @@ -218,7 +218,7 @@ pub async fn extract_tar_file(
}

tracing::debug!(
num_bytes,
num_kilobytes,
elapsed = ?start.elapsed(),
found = found.is_some(),
"extracted tar file"
Expand Down

0 comments on commit 6baeefb

Please sign in to comment.