From 18f24a55a461dbd10c2425ff8f10412eef0366ee Mon Sep 17 00:00:00 2001 From: Christian Schilling Date: Wed, 25 Sep 2024 15:05:58 +0200 Subject: [PATCH] Output backtrace to tracing Without a backtrace it is very difficult to analyse errors and the logs are not always easily accessible Change: tracing-bt --- josh-core/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/josh-core/src/lib.rs b/josh-core/src/lib.rs index e79bd504..6ca5f06b 100644 --- a/josh-core/src/lib.rs +++ b/josh-core/src/lib.rs @@ -155,9 +155,9 @@ where T: std::error::Error, { fn from(item: T) -> Self { - tracing::event!(tracing::Level::ERROR, item = ?item, error = true); - log::error!("JoshError: {:?}", item); let bt = backtrace::Backtrace::new(); + tracing::event!(tracing::Level::ERROR, item = ?item, backtrace = format!("{:?}", bt), error = true); + log::error!("JoshError: {:?}", item); log::error!("Backtrace: {:?}", bt); josh_error(&format!("converted {:?}", item)) }