atagen

monolith

public
Star0
Watch0

Commit cd7973085011

tarball

atagen <boss@atagen.co>2026-10-19 07:54 UTC

2 files changed+6-1
main: log slow spans and panics through tracing

slow_spans printed with eprintln, which never reached the log file, and a panic in a running session left only stderr that nobody captures.
Modified file: crates/monolith/src/main.rs+5 additions
@@ -154,6 +154,11 @@ fn main() -> ExitCode {
154154 if let Some(p) = &log_path {
155155 tracing::info!(path = %p.display(), "logging to a file");
156156 }
157+ let default_hook = std::panic::take_hook();
158+ std::panic::set_hook(Box::new(move |info| {
159+ tracing::error!("{info}");
160+ default_hook(info);
161+ }));
157162 #[cfg(feature = "spans")]
158163 tracing::info!("logging spans slower than {threshold_us} us");
159164 match run(config, backend, &program) {
Modified file: crates/monolith/src/slow_spans.rs+1 additions−1 deletions
@@ -42,7 +42,7 @@ where
4242 let took = at.elapsed();
4343 if took.as_micros() >= self.threshold_us {
4444 let path: Vec<&str> = span.scope().from_root().map(|s| s.name()).collect();
45- eprintln!("slow span {} took_us={}", path.join(">"), took.as_micros());
45+ tracing::info!("slow span {} took_us={}", path.join(">"), took.as_micros());
4646 }
4747 }
4848 }