diff --git a/Cargo.lock b/Cargo.lock index 56fbbfbc0..fb1a508c9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5521,6 +5521,7 @@ dependencies = [ "headers", "home", "html_parser", + "humantime", "hyper 1.8.1", "hyper-rustls 0.27.7", "hyper-util", diff --git a/packages/cli/Cargo.toml b/packages/cli/Cargo.toml index be5b4853e..13a0dcd5f 100644 --- a/packages/cli/Cargo.toml +++ b/packages/cli/Cargo.toml @@ -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 } diff --git a/packages/cli/src/serve/runner.rs b/packages/cli/src/serve/runner.rs index cc08901c7..f17cc40d3 100644 --- a/packages/cli/src/serve/runner.rs +++ b/packages/cli/src/serve/runner.rs @@ -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() +}