Skip to content

Commit 62b7772

Browse files
As-Fburrbull
authored andcommitted
Improve log formatting
Addresses issue tectonic-typesetting#539 - Paths and filenames are now quoted in backticks - File sizes are now expressed in appropriate units (KiB/MiB) This adds a new dependency (byte-unit) for expressing file sizes.
1 parent 8bdd572 commit 62b7772

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ crate-type = ["rlib"]
3434

3535
[dependencies]
3636
app_dirs2 = "^2"
37+
byte-unit = "^3.0"
3738
cfg-if = "0.1"
3839
structopt = "0.3"
3940
error-chain = "^0.12"

src/driver.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//! For an example of how to use this module, see `src/bin/tectonic.rs`, which contains tectonic's main
1212
//! CLI program.
1313
14+
use byte_unit::Byte;
1415
use std::collections::{HashMap, HashSet};
1516
use std::ffi::{OsStr, OsString};
1617
use std::fs::File;
@@ -858,15 +859,20 @@ impl ProcessingSession {
858859
}
859860

860861
if contents.is_empty() {
861-
status.note_highlighted("Not writing ", &sname, ": it would be empty.");
862+
status.note_highlighted(
863+
"Not writing ",
864+
&format!("`{}`", sname),
865+
": it would be empty.",
866+
);
862867
continue;
863868
}
864869

865870
let real_path = root.join(name);
871+
let byte_len = Byte::from_bytes(contents.len() as u128);
866872
status.note_highlighted(
867873
"Writing ",
868-
&real_path.to_string_lossy(),
869-
&format!(" ({} bytes)", contents.len()),
874+
&format!("`{}`", real_path.to_string_lossy()),
875+
&format!(" ({})", byte_len.get_appropriate_unit(true).to_string()),
870876
);
871877

872878
let mut f = File::create(&real_path)?;

0 commit comments

Comments
 (0)