From dbc74a8efa85415096af0a9a1e6d49fdf6a558ca Mon Sep 17 00:00:00 2001 From: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com> Date: Thu, 12 Sep 2024 09:51:34 +1000 Subject: [PATCH] Change output of events in logs from Rust debug to JSON --- cmd/soroban-cli/src/log/event.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/cmd/soroban-cli/src/log/event.rs b/cmd/soroban-cli/src/log/event.rs index 8a4fedfbf..3945ae999 100644 --- a/cmd/soroban-cli/src/log/event.rs +++ b/cmd/soroban-cli/src/log/event.rs @@ -1,4 +1,4 @@ -use tracing::{debug, info, span, Level}; +use tracing::{debug, error, info, span, Level}; use crate::xdr; @@ -14,10 +14,16 @@ pub fn events(events: &[xdr::DiagnosticEvent]) { let _enter = span.enter(); - if span.metadata().unwrap().level() == &Level::INFO { - info!("{i}: {event:#?}"); - } else { - debug!("{i}: {event:#?}"); + let result = serde_json::to_string(event); + match result { + Ok(json) => { + if span.metadata().unwrap().level() == &Level::INFO { + info!("{i}: {json}"); + } else { + debug!("{i}: {json}"); + } + } + Err(err) => error!("converting event to json: {}: ", err), } } }