Skip to content

Commit b724a29

Browse files
authored
fix: add node info on all logs (#88)
1 parent 323d8f5 commit b724a29

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pkg/rpc/node.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,8 @@ func (n *Node) loadStatus() *ctypes.ResultStatus {
222222
}
223223

224224
func (n *Node) syncStatus(ctx context.Context) (*ctypes.ResultStatus, error) {
225+
log := log.With().Str("node", n.Redacted()).Logger()
226+
225227
retryOpts := []retry.Option{
226228
retry.Context(ctx),
227229
retry.Delay(1 * time.Second),
@@ -243,7 +245,7 @@ func (n *Node) syncStatus(ctx context.Context) (*ctypes.ResultStatus, error) {
243245

244246
if status.SyncInfo.CatchingUp {
245247
// We're catching up, not synced
246-
log.Warn().Msgf("node %s is catching up at block %d", n.Redacted(), status.SyncInfo.LatestBlockHeight)
248+
log.Warn().Int64("block", status.SyncInfo.LatestBlockHeight).Msgf("node is catching up")
247249
return status, nil
248250
}
249251

@@ -259,6 +261,8 @@ func (n *Node) syncStatus(ctx context.Context) (*ctypes.ResultStatus, error) {
259261
}
260262

261263
func (n *Node) handleStart(ctx context.Context) {
264+
log := log.With().Str("node", n.Redacted()).Logger()
265+
262266
for _, onStart := range n.onStart {
263267
if err := onStart(ctx, n); err != nil {
264268
log.Error().Err(err).Msgf("failed to call start node callback")
@@ -291,6 +295,8 @@ func (n *Node) saveLatestBlock(block *types.Block) {
291295
}
292296

293297
func (n *Node) syncBlocks(ctx context.Context) {
298+
log := log.With().Str("node", n.Redacted()).Logger()
299+
294300
// Fetch latest block
295301
currentBlockResp, err := n.Client.Block(ctx, nil)
296302
if err != nil {

0 commit comments

Comments
 (0)