Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change output of events in logs from Rust debug to JSON #1600

Merged
merged 4 commits into from
Sep 18, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 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, 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,10 +15,12 @@ pub fn events(events: &[xdr::DiagnosticEvent]) {

let _enter = span.enter();

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}: {event:#?}");
info!("{i}: {xdr} {json}");
} else {
debug!("{i}: {event:#?}");
debug!("{i}: {xdr} {json}");
}
}
}
Expand Down
Loading