Skip to content

Commit

Permalink
fix: print console logs once per call, fix spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
Romsters committed Dec 3, 2024
1 parent 5efab18 commit d63b180
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
14 changes: 9 additions & 5 deletions src/console_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ impl Default for ConsoleLogHandler {
}

impl ConsoleLogHandler {
pub fn handle_calls_recursive(&self, calls: &Vec<Call>) {
tracing::info!("");
tracing::info!("==== Console logs: ");

for call in calls {
self.handle_call_recursive(call);
}
}
pub fn handle_call_recursive(&self, current_call: &Call) {
self.handle_call(current_call);
for call in &current_call.calls {
Expand All @@ -59,11 +67,7 @@ impl ConsoleLogHandler {
tokens.iter().map(|t| format!("{}", t)).join(" ")
})
});
if !message.is_empty() {
tracing::info!("");
tracing::info!("==== Console logs: ");
tracing::info!("{}", message.cyan());
}
tracing::info!("{}", message.cyan());
}
}

Expand Down
2 changes: 0 additions & 2 deletions src/formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -629,8 +629,6 @@ impl Formatter {
}
}
});

tracing::info!("");
}
}
// Builds the branched prefix for the structured logs.
Expand Down
10 changes: 4 additions & 6 deletions src/node/in_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1227,6 +1227,7 @@ impl<S: ForkSource + std::fmt::Debug + Clone> InMemoryNode<S> {
.unwrap_or_default();

if inner.config.show_tx_summary {
tracing::info!("");
match &tx_result.result {
ExecutionResult::Success { output } => {
tracing::info!("Call: {}", "SUCCESS".green());
Expand All @@ -1243,12 +1244,11 @@ impl<S: ForkSource + std::fmt::Debug + Clone> InMemoryNode<S> {
}

Check warning on line 1244 in src/node/in_memory.rs

View workflow job for this annotation

GitHub Actions / lint

Diff in /home/runner/work/era-test-node/era-test-node/src/node/in_memory.rs

Check warning on line 1244 in src/node/in_memory.rs

View workflow job for this annotation

GitHub Actions / lint

Diff in /home/runner/work/era-test-node/era-test-node/src/node/in_memory.rs

if !inner.config.disable_console_log {
for call in &call_traces {
inner.console_log_handler.handle_call_recursive(call);
}
inner.console_log_handler.handle_calls_recursive(&call_traces);
}

if inner.config.show_calls != ShowCalls::None {
tracing::info!("");
tracing::info!(
"[Transaction Execution] ({} calls)",
call_traces[0].calls.len()
Expand Down Expand Up @@ -1425,9 +1425,7 @@ impl<S: ForkSource + std::fmt::Debug + Clone> InMemoryNode<S> {
}

Check warning on line 1425 in src/node/in_memory.rs

View workflow job for this annotation

GitHub Actions / lint

Diff in /home/runner/work/era-test-node/era-test-node/src/node/in_memory.rs

Check warning on line 1425 in src/node/in_memory.rs

View workflow job for this annotation

GitHub Actions / lint

Diff in /home/runner/work/era-test-node/era-test-node/src/node/in_memory.rs

if !inner.config.disable_console_log {
for call in call_traces {
inner.console_log_handler.handle_call_recursive(call);
}
inner.console_log_handler.handle_calls_recursive(&call_traces);
}

if inner.config.show_calls != ShowCalls::None {
Expand Down

0 comments on commit d63b180

Please sign in to comment.