From 1c242baa7e3e467ecfc58104bc67a84a5ad45726 Mon Sep 17 00:00:00 2001 From: David Flanagan Date: Tue, 19 May 2026 19:20:16 +0100 Subject: [PATCH] fix(server): replace production eprintln! with tracing macros (#11) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Final acceptance gate on #11. The graceful-shutdown path was the last production code in crates/server/src/ using `eprintln!`; the two other `eprintln!` matches are test-only "SKIP: bundler not run" hints inside `#[test]` functions (wasm_host.rs, wasm_registry.rs), which #11's acceptance explicitly permits ("0 or only test-only matches"). Sites converted (all in `crates/server/src/main.rs`): - `serve error` → `tracing::error!(%error, ...)` - `drain timeout` → `tracing::warn!(timeout_seconds = ..., ...)` - `draining complete` → `tracing::info!` - `events.jsonl / audit.jsonl fsync failed` → `tracing::error!` with path field - SIGINT / SIGTERM received → `tracing::info!` - ctrl_c handler failed → `tracing::error!` Now flow through the tracing subscriber added in PR #28 instead of bypassing it. Production aggregators see a single JSON stream including shutdown events. 175/175 server tests green; clippy clean. --- crates/server/src/main.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/server/src/main.rs b/crates/server/src/main.rs index 2283654e..9cae00d4 100644 --- a/crates/server/src/main.rs +++ b/crates/server/src/main.rs @@ -212,22 +212,22 @@ async fn main() { match tokio::time::timeout(SHUTDOWN_DRAIN_TIMEOUT, serve).await { Ok(Ok(())) => {} Ok(Err(error)) => { - eprintln!("graceful shutdown: serve error: {error}"); + tracing::error!(%error, "graceful shutdown: serve error"); } Err(_elapsed) => { - eprintln!( - "graceful shutdown: drain exceeded {}s; aborting in-flight", - SHUTDOWN_DRAIN_TIMEOUT.as_secs() + tracing::warn!( + timeout_seconds = SHUTDOWN_DRAIN_TIMEOUT.as_secs(), + "graceful shutdown: drain timeout exceeded; aborting in-flight" ); } } - eprintln!("graceful shutdown: draining complete; flushing logs"); + tracing::info!("graceful shutdown: draining complete; flushing logs"); if let Err(error) = fsync_jsonl_path(&events_path) { - eprintln!("graceful shutdown: events.jsonl fsync failed: {error}"); + tracing::error!(%error, path = ?events_path, "graceful shutdown: events.jsonl fsync failed"); } if let Err(error) = fsync_jsonl_path(&audit_path) { - eprintln!("graceful shutdown: audit.jsonl fsync failed: {error}"); + tracing::error!(%error, path = ?audit_path, "graceful shutdown: audit.jsonl fsync failed"); } } @@ -239,12 +239,12 @@ async fn shutdown_signal(mut sigterm: tokio::signal::unix::Signal) { tokio::select! { ctrlc = tokio::signal::ctrl_c() => { if let Err(error) = ctrlc { - eprintln!("graceful shutdown: ctrl_c handler failed: {error}"); + tracing::error!(%error, "graceful shutdown: ctrl_c handler failed"); } - eprintln!("graceful shutdown: SIGINT received"); + tracing::info!("graceful shutdown: SIGINT received"); } _ = sigterm.recv() => { - eprintln!("graceful shutdown: SIGTERM received"); + tracing::info!("graceful shutdown: SIGTERM received"); } } }