Enforce log.WithError(err) static analysis and fix all violations (#11163)

* Use log.WithError static analysis from #11143 and fix all violations

* Fix another log violation after pulling from develop

* Update beacon-chain/sync/pending_blocks_queue.go

Co-authored-by: Potuz <potuz@prysmaticlabs.com>

* @potuz feedback

* Copy paste fail

* fix tests

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
Co-authored-by: Potuz <potuz@prysmaticlabs.com>
This commit is contained in:
Preston Van Loon
2022-08-05 05:52:02 -05:00
committed by GitHub
parent 1323912625
commit 9d375969d1
61 changed files with 193 additions and 175 deletions

View File

@@ -6,6 +6,7 @@ import (
"strings"
"github.com/golang-jwt/jwt/v4"
"github.com/sirupsen/logrus"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/metadata"
@@ -24,7 +25,10 @@ func (s *Server) JWTInterceptor() grpc.UnaryServerInterceptor {
return nil, err
}
h, err := handler(ctx, req)
log.Debugf("Request - Method: %s, Error: %v\n", info.FullMethod, err)
log.WithError(err).WithFields(logrus.Fields{
"FullMethod": info.FullMethod,
"Server": info.Server,
}).Debug("Request handled")
return h, err
}
}

View File

@@ -132,7 +132,7 @@ func (s *Server) Start() {
address := fmt.Sprintf("%s:%s", s.host, s.port)
lis, err := net.Listen("tcp", address)
if err != nil {
log.Errorf("Could not listen to port in Start() %s: %v", address, err)
log.WithError(err).Errorf("Could not listen to port in Start() %s", address)
}
s.listener = lis
@@ -182,7 +182,7 @@ func (s *Server) Start() {
go func() {
if s.listener != nil {
if err := s.grpcServer.Serve(s.listener); err != nil {
log.Errorf("Could not serve: %v", err)
log.WithError(err).Error("Could not serve")
}
}
}()
@@ -190,7 +190,7 @@ func (s *Server) Start() {
if s.walletDir != "" {
token, err := s.initializeAuthToken(s.walletDir)
if err != nil {
log.Errorf("Could not initialize web auth token: %v", err)
log.WithError(err).Error("Could not initialize web auth token")
return
}
validatorWebAddr := fmt.Sprintf("%s:%d", s.validatorGatewayHost, s.validatorGatewayPort)

View File

@@ -173,7 +173,7 @@ func (s *Server) DeleteKeystores(
exportedHistory, err := s.slashingProtectionHistoryForDeletedKeys(ctx, req.Pubkeys, statuses)
if err != nil {
log.Warnf("Could not get slashing protection history for deleted keys: %v", err)
log.WithError(err).Warn("Could not get slashing protection history for deleted keys")
statuses := groupExportErrors(req, "Non duplicate keys that were existing were deleted, but could not export slashing protection history.")
return &ethpbservice.DeleteKeystoresResponse{Data: statuses}, nil
}