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
@@ -108,6 +108,7 @@ tracing-subscriber = { version = "0.3.19", features = [
|
||||
"fmt",
|
||||
] }
|
||||
console-subscriber = { version = "0.4.1", optional = true }
|
||||
humantime = "2.2.0"
|
||||
tracing = { workspace = true }
|
||||
ansi-to-tui = { workspace = true }
|
||||
ansi-to-html = { workspace = true }
|
||||
|
||||
@@ -604,13 +604,13 @@ impl AppServer {
|
||||
|
||||
if self.client.builds_opened == 0 {
|
||||
tracing::info!(
|
||||
"Build completed successfully in {GLOW_STYLE}{:?}ms{GLOW_STYLE:#}, launching app! 💫",
|
||||
time_taken.as_millis()
|
||||
"Build completed successfully in {GLOW_STYLE}{}{GLOW_STYLE:#}, launching app! 💫",
|
||||
format_duration_ms(time_taken)
|
||||
);
|
||||
} else {
|
||||
tracing::info!(
|
||||
"Build completed in {GLOW_STYLE}{:?}ms{GLOW_STYLE:#}",
|
||||
time_taken.as_millis()
|
||||
"Build completed in {GLOW_STYLE}{}{GLOW_STYLE:#}",
|
||||
format_duration_ms(time_taken)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1308,3 +1308,10 @@ fn is_wsl() -> bool {
|
||||
|
||||
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