Skip to content

Commit

Permalink
more structured logging
Browse files Browse the repository at this point in the history
  • Loading branch information
4meta5 committed Jul 16, 2024
1 parent 8dde8b0 commit 336bfd0
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 deletions.
7 changes: 6 additions & 1 deletion chronicle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,12 @@ pub async fn run_chronicle(
}
};

tracing::info!("Target wallet address: {:?}", task_spawner.target_address());
event!(
target: TW_LOG,
Level::INFO,
"Target wallet address: {:?}",
task_spawner.target_address()
);

// Run the main application loop with the initialized task spawner.
run_chronicle_with_spawner(
Expand Down
8 changes: 6 additions & 2 deletions chronicle/src/network/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use futures::{Future, FutureExt, SinkExt};
use peernet::{Endpoint, NotificationHandler, Protocol, ProtocolHandler};
use std::pin::Pin;
use std::time::Duration;
use tracing::field;

pub struct TssEndpoint {
endpoint: Endpoint,
Expand Down Expand Up @@ -65,7 +66,10 @@ impl TssEndpoint {
let endpoint = builder.build().await?;
let peer_id = endpoint.peer_id();
loop {
tracing::info!("waiting for peer id to be registered");
tracing::info!(
peer_id = field::display(peer_id.clone()),
"waiting for peer id to be registered",
);
let Ok(addr) = endpoint.resolve(peer_id).await else {
tokio::time::sleep(Duration::from_secs(1)).await;
continue;
Expand All @@ -74,7 +78,7 @@ impl TssEndpoint {
tokio::time::sleep(Duration::from_secs(1)).await;
continue;
}
tracing::info!("peer id registered");
tracing::info!(peer_id = field::display(peer_id.clone()), "peer id registered",);
break;
}
Ok(Self { endpoint })
Expand Down
8 changes: 7 additions & 1 deletion chronicle/src/shards/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,13 @@ where
event!(target: TW_LOG, parent: span, Level::INFO, "submitted heartbeat");
}
if let Err(e) = self.on_finality(span, block_hash, block_number).await {
tracing::error!("Error running on_finality {:?}", e);
event!(
target: TW_LOG,
parent: span,
Level::ERROR,
"Error running on_finality {:?}",
e
);
}
},
tss_request = self.tss_request.next().fuse() => {
Expand Down
15 changes: 14 additions & 1 deletion chronicle/src/tasks/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,12 +368,25 @@ where
shard_id: ShardId,
block_hash: BlockHash,
) -> Result<Option<GmpParams>> {
let span = span!(
target: TW_LOG,
Level::ERROR,
"gmp_params",
block = block_hash.to_string(),
shard_id,
);
let Some(gateway_contract) = self.substrate.get_gateway(self.network).await? else {
return Ok(None);
};
let Some(commitment) = self.substrate.get_shard_commitment(block_hash, shard_id).await?
else {
tracing::error!(target: "chronicle", "shard commitment is empty for shard: {shard_id}");
event!(
target: TW_LOG,
parent: &span,
Level::ERROR,
shard_id,
"empty shard commitment",
);
return Ok(None);
};
Ok(Some(GmpParams {
Expand Down

0 comments on commit 336bfd0

Please sign in to comment.