Log with field error instead of err (#7998)

This commit is contained in:
Potuz 2020-12-01 10:38:42 -03:00 committed by GitHub
parent a13de7da11
commit 9a1423d62d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -110,7 +110,7 @@ func (s *Service) processFetchedData(
// Use Batch Block Verify to process and verify batches directly.
if err := s.processBatchedBlocks(ctx, genesis, data.blocks, s.chain.ReceiveBlockBatch); err != nil {
log.WithField("err", err.Error()).Warn("Batch is not processed")
log.WithError(err).Warn("Batch is not processed")
}
}
@ -125,20 +125,20 @@ func (s *Service) processFetchedDataRegSync(
if err := s.processBlock(ctx, genesis, blk, blockReceiver); err != nil {
switch {
case errors.Is(err, errBlockAlreadyProcessed):
log.WithField("err", err.Error()).Debug("Block is not processed")
log.WithError(err).Debug("Block is not processed")
invalidBlocks++
case errors.Is(err, errParentDoesNotExist):
log.WithField("err", err.Error()).Debug("Block is not processed")
log.WithError(err).Debug("Block is not processed")
invalidBlocks++
default:
log.WithField("err", err.Error()).Warn("Block is not processed")
log.WithError(err).Warn("Block is not processed")
}
continue
}
}
// Add more visible logging if all blocks cannot be processed.
if len(data.blocks) == invalidBlocks {
log.WithField("err", "Range had no valid blocks to process").Warn("Range is not processed")
log.WithField("error", "Range had no valid blocks to process").Warn("Range is not processed")
}
}