From fa77a949aa9cef002b24659532ec6a4ef140e2ca Mon Sep 17 00:00:00 2001 From: Louis Dureuil Date: Mon, 29 Jul 2024 14:58:39 +0200 Subject: [PATCH] Log error from main using tracing --- meilisearch/src/main.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/meilisearch/src/main.rs b/meilisearch/src/main.rs index e881734fb..2e70b4eb7 100644 --- a/meilisearch/src/main.rs +++ b/meilisearch/src/main.rs @@ -72,6 +72,19 @@ fn on_panic(info: &std::panic::PanicInfo) { #[actix_web::main] async fn main() -> anyhow::Result<()> { + try_main().await.inspect_err(|error| { + tracing::error!(%error); + let mut current = error.source(); + let mut depth = 0; + while let Some(source) = current { + tracing::info!(%source, depth, "Error caused by"); + current = source.source(); + depth += 1; + } + }) +} + +async fn try_main() -> anyhow::Result<()> { let (opt, config_read_from) = Opt::try_build()?; std::panic::set_hook(Box::new(on_panic));