Skip to content

Commit

Permalink
improve logging
Browse files Browse the repository at this point in the history
  • Loading branch information
cre4ture committed Apr 28, 2024
1 parent aac48d1 commit 2a01ce4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
21 changes: 13 additions & 8 deletions src/uu/ls/src/ls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2610,24 +2610,29 @@ fn get_block_size(md: &Metadata, config: &Config) -> u64 {
md.blocks() * 512
};

let result = match config.size_format {
SizeFormat::Binary | SizeFormat::Decimal => raw_blocks,
SizeFormat::Bytes => {
(raw_blocks + config.block_size - 1/* ceiling div */) / config.block_size
}
};

log::debug!(
"md.file_type().is_char_device(): {}, md.file_type().is_block_device(): {},\
blocks: {}, size: {}, raw: {}, cfg.block_size: {}, cfg.size_format: {:?}",
"is_char_device: {}, is_block_device(): {}, \
blocks: {}, size: {}, raw: {}, \
cfg.block_size: {}, result: {}, \
cfg.size_format: {:?}",
md.file_type().is_char_device(),
md.file_type().is_block_device(),
md.blocks(),
md.size(),
raw_blocks,
config.block_size,
result,
config.size_format
);

match config.size_format {
SizeFormat::Binary | SizeFormat::Decimal => raw_blocks,
SizeFormat::Bytes => {
(raw_blocks + config.block_size - 1/* ceiling div */) / config.block_size
}
}
result
}
#[cfg(not(unix))]
{
Expand Down
1 change: 0 additions & 1 deletion src/uucore/src/lib/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ mod macros; // crate macros (macro_rules-type; exported to `crate::...`)
mod mods; // core cross-platform modules
mod parser; // string parsing modules

use log::info;
use log::LevelFilter;
pub use uucore_procs::*;

Expand Down
2 changes: 1 addition & 1 deletion tests/common/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1204,7 +1204,7 @@ impl Drop for LogPrintGuard {

std::io::stderr().flush().unwrap();
let mut reader = std::io::BufReader::new(f);
let result = std::io::copy(&mut reader, &mut PrintSink{}).unwrap_or_else(|e| {
let result = std::io::copy(&mut reader, &mut PrintSink {}).unwrap_or_else(|e| {
eprintln!(
"Failed to read contents of log-file: {}, Err: {:?}",
self.log_file.display(),
Expand Down

0 comments on commit 2a01ce4

Please sign in to comment.