Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(log): add Warn log level and decrease verbosity of some logs #790

Merged
merged 2 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion abci/server/socket_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (s *SocketServer) acceptConnectionsRoutine(ctx context.Context) {
if !s.IsRunning() {
return // Ignore error from listener closing.
}
s.logger.Error("Failed to accept connection", "err", err)
s.logger.Warn("Failed to accept connection", "err", err)
continue
}

Expand Down
10 changes: 5 additions & 5 deletions internal/p2p/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ func (r *Router) acceptPeers(ctx context.Context, transport Transport) {
return
case err != nil:
// in this case we got an error from the net.Listener.
r.logger.Error("failed to accept connection", "transport", transport, "err", err)
r.logger.Warn("failed to accept connection", "transport", transport, "err", err)
continue
}

Expand Down Expand Up @@ -503,7 +503,7 @@ func (r *Router) openConnection(ctx context.Context, conn Connection) {

err = r.peerManager.Accepted(peerInfo.NodeID, SetProTxHashToPeerInfo(peerInfo.ProTxHash))
if err != nil {
r.logger.Error("failed to accept connection",
r.logger.Warn("failed to accept connection",
"op", "incoming/accepted", "peer", peerInfo.NodeID, "err", err)
return
}
Expand Down Expand Up @@ -766,16 +766,16 @@ func (r *Router) routePeer(ctx context.Context, peerID types.NodeID, conn Connec
_ = conn.Close()
sendQueue.close()

r.logger.Debug("routePeer: closed conn and send queue, waiting for all goroutines to finish", "peer", peerID, "err", err)
r.logger.Trace("routePeer: closed conn and send queue, waiting for all goroutines to finish", "peer", peerID, "err", err)
wg.Wait()
r.logger.Debug("routePeer: all goroutines finished", "peer", peerID, "err", err)
r.logger.Trace("routePeer: all goroutines finished", "peer", peerID, "err", err)

// Drain the error channel; these should typically not be interesting
FOR:
for {
select {
case e := <-errCh:
r.logger.Debug("routePeer: received error when draining errCh", "peer", peerID, "err", e)
r.logger.Trace("routePeer: received error when draining errCh", "peer", peerID, "err", e)
// if we received non-context error, we should return it
if err == nil && !errors.Is(e, context.Canceled) && !errors.Is(e, context.DeadlineExceeded) {
err = e
Expand Down
2 changes: 1 addition & 1 deletion internal/statesync/reactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,7 @@ func (r *Reactor) processPeerUp(ctx context.Context, peerUpdate p2p.PeerUpdate)

r.peers.Append(peerUpdate.NodeID)
} else {
r.logger.Error("could not use peer for statesync", "peer", peerUpdate.NodeID)
r.logger.Warn("could not use peer for statesync", "peer", peerUpdate.NodeID)
}
newProvider := NewBlockProvider(peerUpdate.NodeID, r.chainID, r.dispatcher)

Expand Down
4 changes: 4 additions & 0 deletions libs/log/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ func (l defaultLogger) Info(msg string, keyVals ...interface{}) {
l.Logger.Info().Fields(getLogFields(keyVals...)).Msg(msg)
}

func (l defaultLogger) Warn(msg string, keyVals ...interface{}) {
l.Logger.Warn().Fields(getLogFields(keyVals...)).Msg(msg)
}

func (l defaultLogger) Error(msg string, keyVals ...interface{}) {
l.Logger.Error().Fields(getLogFields(keyVals...)).Msg(msg)
}
Expand Down
8 changes: 8 additions & 0 deletions libs/log/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,17 @@ const (
type Logger interface {
io.Closer

// Trace events are logged from the primary path of execution (eg. when everything goes well)
Trace(msg string, keyVals ...interface{})
// Debug events are used in non-primary path to provide fine-grained information useful for debugging
Debug(msg string, keyVals ...interface{})
// Info events provide general, business-level information about what's happening inside the application, to
// let the user know what the application is doing
Info(msg string, keyVals ...interface{})
// Warn events are used when something unexpected happened, but the application can recover/continue
Warn(msg string, keyVals ...interface{})
// Error events are used when something unexpected happened and the application cannot recover, or the
// issue is serious and the user needs to take action
Error(msg string, keyVals ...interface{})

With(keyVals ...interface{}) Logger
Expand Down
19 changes: 0 additions & 19 deletions types/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (

sync "github.com/sasha-s/go-deadlock"

"github.com/dashpay/dashd-go/btcjson"
"github.com/gogo/protobuf/proto"
gogotypes "github.com/gogo/protobuf/types"
"github.com/rs/zerolog"
Expand Down Expand Up @@ -816,24 +815,6 @@ func (commit *Commit) VoteBlockRequestID() []byte {
return hash[:]
}

// CanonicalVoteVerifySignBytes returns the bytes of the Canonical Vote that is threshold signed.
func (commit *Commit) CanonicalVoteVerifySignBytes(chainID string) []byte {
voteCanonical := commit.GetCanonicalVote()
vCanonical := voteCanonical.ToProto()
bz, err := vCanonical.SignBytes(chainID)
if err != nil {
panic(fmt.Errorf("canonical vote sign bytes: %w", err))
}
return bz
}

// CanonicalVoteVerifySignID returns the signID bytes of the Canonical Vote that is threshold signed.
func (commit *Commit) CanonicalVoteVerifySignID(chainID string, quorumType btcjson.LLMQType, quorumHash []byte) []byte {
voteCanonical := commit.GetCanonicalVote()
vCanonical := voteCanonical.ToProto()
return VoteBlockSignID(chainID, vCanonical, quorumType, quorumHash)
}

// Type returns the vote type of the commit, which is always VoteTypePrecommit
// Implements VoteSetReader.
func (commit *Commit) Type() byte {
Expand Down
Loading