Skip to content

Commit

Permalink
Change output of events in logs from Rust debug to JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
leighmcculloch committed Sep 11, 2024
1 parent dd14b52 commit dbc74a8
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions cmd/soroban-cli/src/log/event.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use tracing::{debug, info, span, Level};
use tracing::{debug, error, info, span, Level};

use crate::xdr;

Expand All @@ -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),
}
}
}
Expand Down

0 comments on commit dbc74a8

Please sign in to comment.