From b22a261bc23be8b6eaf591ed9cbe020a5f4dba2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Thu, 4 Feb 2021 17:08:24 +0100 Subject: [PATCH] using zap.NewNop() ignores configured log level MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jakub SokoĊ‚owski --- protocol/encryption/publisher/publisher.go | 3 ++- waku/waku.go | 14 ++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/protocol/encryption/publisher/publisher.go b/protocol/encryption/publisher/publisher.go index 28ea2af25..500662ce6 100644 --- a/protocol/encryption/publisher/publisher.go +++ b/protocol/encryption/publisher/publisher.go @@ -8,6 +8,7 @@ import ( "go.uber.org/zap" "github.com/status-im/status-go/eth-node/crypto" + "github.com/status-im/status-go/logutils" ) const ( @@ -32,7 +33,7 @@ type Publisher struct { func New(logger *zap.Logger) *Publisher { if logger == nil { - logger = zap.NewNop() + logger = logutils.ZapLogger() } return &Publisher{ diff --git a/waku/waku.go b/waku/waku.go index 74c6d0979..ae2345f15 100644 --- a/waku/waku.go +++ b/waku/waku.go @@ -38,13 +38,13 @@ import ( gethcommon "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/event" - "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/p2p" "github.com/ethereum/go-ethereum/p2p/enode" "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rpc" "github.com/status-im/status-go/eth-node/types" + "github.com/status-im/status-go/logutils" "github.com/status-im/status-go/waku/common" v0 "github.com/status-im/status-go/waku/v0" v1 "github.com/status-im/status-go/waku/v1" @@ -116,7 +116,7 @@ type Waku struct { // New creates a Waku client ready to communicate through the Ethereum P2P network. func New(cfg *Config, logger *zap.Logger) *Waku { if logger == nil { - logger = zap.NewNop() + logger = logutils.ZapLogger() } logger.Debug("starting waku with config", zap.Any("config", cfg)) @@ -1331,7 +1331,7 @@ func (w *Waku) addAndBridge(envelope *common.Envelope, isP2P bool, bridged bool) if sent > now { if sent-common.DefaultSyncAllowance > now { common.EnvelopesCacheFailedCounter.WithLabelValues("in_future").Inc() - log.Warn("envelope created in the future", "hash", envelope.Hash()) + w.logger.Warn("envelope created in the future", zap.ByteString("hash", envelope.Hash().Bytes())) return false, common.TimeSyncError(errors.New("envelope from future")) } // recalculate PoW, adjusted for the time difference, plus one second for latency @@ -1341,10 +1341,10 @@ func (w *Waku) addAndBridge(envelope *common.Envelope, isP2P bool, bridged bool) if envelope.Expiry < now { if envelope.Expiry+common.DefaultSyncAllowance*2 < now { common.EnvelopesCacheFailedCounter.WithLabelValues("very_old").Inc() - log.Warn("very old envelope", "hash", envelope.Hash()) + w.logger.Warn("very old envelope", zap.ByteString("hash", envelope.Hash().Bytes())) return false, common.TimeSyncError(errors.New("very old envelope")) } - log.Debug("expired envelope dropped", "hash", envelope.Hash().Hex()) + w.logger.Debug("expired envelope dropped", zap.ByteString("hash", envelope.Hash().Bytes())) common.EnvelopesCacheFailedCounter.WithLabelValues("expired").Inc() return false, nil // drop envelope without error } @@ -1383,10 +1383,8 @@ func (w *Waku) addAndBridge(envelope *common.Envelope, isP2P bool, bridged bool) } if alreadyCached { - log.Trace("w envelope already cached", "hash", envelope.Hash().Hex()) common.EnvelopesCachedCounter.WithLabelValues("hit").Inc() } else { - log.Trace("cached w envelope", "hash", envelope.Hash().Hex()) common.EnvelopesCachedCounter.WithLabelValues("miss").Inc() common.EnvelopesSizeMeter.Observe(float64(envelope.Size())) w.postEvent(envelope, isP2P) // notify the local node about the new message @@ -1402,7 +1400,7 @@ func (w *Waku) addAndBridge(envelope *common.Envelope, isP2P bool, bridged bool) // In particular, if a node is a lightweight node, // it should not bridge any envelopes. if !isP2P && !bridged && w.bridge != nil { - log.Debug("bridging envelope from Waku", "hash", envelope.Hash().Hex()) + w.logger.Debug("bridging envelope from Waku", zap.ByteString("hash", envelope.Hash().Bytes())) _, in := w.bridge.Pipe() in <- envelope common.BridgeSent.Inc()