Skip to content

Commit

Permalink
feat(node-core): omit stage progress from logs if empty (paradigmxyz#…
Browse files Browse the repository at this point in the history
  • Loading branch information
shekhirin committed Mar 19, 2024
1 parent 8cddc40 commit 1bf5d6a
Showing 1 changed file with 44 additions and 22 deletions.
66 changes: 44 additions & 22 deletions crates/node-core/src/events/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,32 +147,54 @@ impl<DB> NodeState<DB> {
current_stage.eta.update(stage_id, checkpoint);

let target = OptionalField(current_stage.target);
let stage_progress = OptionalField(
checkpoint.entities().and_then(|entities| entities.fmt_percentage()),
);
let stage_progress =
checkpoint.entities().and_then(|entities| entities.fmt_percentage());
let stage_eta = current_stage.eta.fmt_for_stage(stage_id);

let message =
if done { "Stage finished executing" } else { "Stage committed progress" };

if let Some(stage_eta) = current_stage.eta.fmt_for_stage(stage_id) {
info!(
pipeline_stages = %pipeline_stages_progress,
stage = %stage_id,
checkpoint = %checkpoint.block_number,
%target,
%stage_progress,
%stage_eta,
"{message}",
)
} else {
info!(
pipeline_stages = %pipeline_stages_progress,
stage = %stage_id,
checkpoint = %checkpoint.block_number,
%target,
%stage_progress,
"{message}",
)
match (stage_progress, stage_eta) {
(Some(stage_progress), Some(stage_eta)) => {
info!(
pipeline_stages = %pipeline_stages_progress,
stage = %stage_id,
checkpoint = %checkpoint.block_number,
%target,
%stage_progress,
%stage_eta,
"{message}",
)
}
(Some(stage_progress), None) => {
info!(
pipeline_stages = %pipeline_stages_progress,
stage = %stage_id,
checkpoint = %checkpoint.block_number,
%target,
%stage_progress,
"{message}",
)
}
(None, Some(stage_eta)) => {
info!(
pipeline_stages = %pipeline_stages_progress,
stage = %stage_id,
checkpoint = %checkpoint.block_number,
%target,
%stage_eta,
"{message}",
)
}
(None, None) => {
info!(
pipeline_stages = %pipeline_stages_progress,
stage = %stage_id,
checkpoint = %checkpoint.block_number,
%target,
"{message}",
)
}
}
}

Expand Down

0 comments on commit 1bf5d6a

Please sign in to comment.