Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
leighmcculloch committed Sep 12, 2024
1 parent dbc74a8 commit da7a3f6
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions cmd/soroban-cli/src/log/event.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use tracing::{debug, error, info, span, Level};
use tracing::{debug, info, span, Level};

use crate::xdr;
use xdr::WriteXdr;

pub fn events(events: &[xdr::DiagnosticEvent]) {
for (i, event) in events.iter().enumerate() {
Expand All @@ -14,16 +15,12 @@ pub fn events(events: &[xdr::DiagnosticEvent]) {

let _enter = span.enter();

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),
let xdr = event.to_xdr_base64(xdr::Limits::none()).unwrap();
let json = serde_json::to_string(event).unwrap();
if span.metadata().unwrap().level() == &Level::INFO {
info!("{i}: {xdr} {json}");
} else {
debug!("{i}: {xdr} {json}");
}
}
}
Expand Down

0 comments on commit da7a3f6

Please sign in to comment.