Enhance CLI Build Duration Output with Human-Readable Formatting (#4591)
* Use humantime for build duration formatting in CLI Replaces manual millisecond formatting with humantime::format_duration for improved readability of build duration logs. Adds humantime as a dependency in Cargo.toml. * Format build duration with millisecond precision Changed build duration logging to use millisecond precision instead of default formatting to avoid microsecond/nanosecond noise. * Refactor duration formatting to use helper function to reduce code duplication. --------- Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
This commit is contained in:
1 parent
8c1911c268
commit
128a9d9fad
3 files changed
+13
-4
No files matched your search
Generated
+1
@@ -5521,6 +5521,7 @@ dependencies = [
|
|||||||
"headers",
|
"headers",
|
||||||
"home",
|
"home",
|
||||||
"html_parser",
|
"html_parser",
|
||||||
|
"humantime",
|
||||||
"hyper 1.8.1",
|
"hyper 1.8.1",
|
||||||
"hyper-rustls 0.27.7",
|
"hyper-rustls 0.27.7",
|
||||||
"hyper-util",
|
"hyper-util",
|
||||||
|
|||||||
@@ -108,6 +108,7 @@ tracing-subscriber = { version = "0.3.19", features = [
|
|||||||
"fmt",
|
"fmt",
|
||||||
] }
|
] }
|
||||||
console-subscriber = { version = "0.4.1", optional = true }
|
console-subscriber = { version = "0.4.1", optional = true }
|
||||||
|
humantime = "2.2.0"
|
||||||
tracing = { workspace = true }
|
tracing = { workspace = true }
|
||||||
ansi-to-tui = { workspace = true }
|
ansi-to-tui = { workspace = true }
|
||||||
ansi-to-html = { workspace = true }
|
ansi-to-html = { workspace = true }
|
||||||
|
|||||||
@@ -604,13 +604,13 @@ impl AppServer {
|
|||||||
|
|
||||||
if self.client.builds_opened == 0 {
|
if self.client.builds_opened == 0 {
|
||||||
tracing::info!(
|
tracing::info!(
|
||||||
"Build completed successfully in {GLOW_STYLE}{:?}ms{GLOW_STYLE:#}, launching app! 💫",
|
"Build completed successfully in {GLOW_STYLE}{}{GLOW_STYLE:#}, launching app! 💫",
|
||||||
time_taken.as_millis()
|
format_duration_ms(time_taken)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
tracing::info!(
|
tracing::info!(
|
||||||
"Build completed in {GLOW_STYLE}{:?}ms{GLOW_STYLE:#}",
|
"Build completed in {GLOW_STYLE}{}{GLOW_STYLE:#}",
|
||||||
time_taken.as_millis()
|
format_duration_ms(time_taken)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1308,3 +1308,10 @@ fn is_wsl() -> bool {
|
|||||||
|
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Format a Duration for human-readable output with millisecond precision.
|
||||||
|
fn format_duration_ms(d: Duration) -> String {
|
||||||
|
// Format duration with millisecond precision to avoid microsecond/nanosecond noise.
|
||||||
|
// See: https://github.com/chronotope/humantime/issues/35
|
||||||
|
humantime::format_duration(Duration::from_millis(d.as_millis() as u64)).to_string()
|
||||||
|
}
|
||||||
Reference in new issue
Block a user