From 61c9e83f60f7c52a433d174c33a672b949ca3fd1 Mon Sep 17 00:00:00 2001 From: Patryk Osmaczko Date: Tue, 3 Dec 2024 23:58:03 +0100 Subject: [PATCH] chore(logging)_: default waku node logs to INFO level This ensures waku node logs remain at INFO level, even if the global logging level is set lower (e.g. DEBUG). To enable waku logs at a specific level, one can execute: `wakuext_setLogNamespaces([{"logNamespaces": "wakunode:debug"}])`. iterates: status-im/status-desktop#16511 --- .../sql/1733335056_default_log_namespaces.up.sql | 6 ++++++ wakuv2/message_publishing.go | 2 +- wakuv2/waku.go | 8 ++++---- 3 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 appdatabase/migrations/sql/1733335056_default_log_namespaces.up.sql diff --git a/appdatabase/migrations/sql/1733335056_default_log_namespaces.up.sql b/appdatabase/migrations/sql/1733335056_default_log_namespaces.up.sql new file mode 100644 index 00000000000..9001e2e5d57 --- /dev/null +++ b/appdatabase/migrations/sql/1733335056_default_log_namespaces.up.sql @@ -0,0 +1,6 @@ +UPDATE log_config +SET + log_namespaces = 'wakunode:info' +WHERE + log_namespaces IS NULL + OR log_namespaces = ''; diff --git a/wakuv2/message_publishing.go b/wakuv2/message_publishing.go index 93543bc6e39..c49532ec04f 100644 --- a/wakuv2/message_publishing.go +++ b/wakuv2/message_publishing.go @@ -86,7 +86,7 @@ func (w *Waku) publishEnvelope(envelope *protocol.Envelope) { var err error // only used in testing to simulate going offline if w.cfg.SkipPublishToTopic { - logger.Info("skipping publish to topic") + logger.Debug("skipping publish to topic") err = errors.New("test send failure") } else { err = w.messageSender.Send(publish.NewRequest(w.ctx, envelope)) diff --git a/wakuv2/waku.go b/wakuv2/waku.go index 1fc541bd2f7..8df2a430f76 100644 --- a/wakuv2/waku.go +++ b/wakuv2/waku.go @@ -289,7 +289,7 @@ func New(nodeKey *ecdsa.PrivateKey, fleet string, cfg *Config, logger *zap.Logge node.WithConnectionNotification(waku.connectionNotifChan), node.WithTopicHealthStatusChannel(waku.topicHealthStatusChan), node.WithKeepAlive(randomPeersKeepAliveInterval, allPeersKeepAliveInterval), - node.WithLogger(logger), + node.WithLogger(logger.Named("wakunode")), node.WithLogLevel(logger.Level()), node.WithClusterID(cfg.ClusterID), node.WithMaxMsgSize(1024 * 1024), @@ -609,7 +609,7 @@ func (w *Waku) runPeerExchangeLoop() { w.logger.Debug("Peer exchange loop stopped") return case <-ticker.C: - w.logger.Info("Running peer exchange loop") + w.logger.Debug("Running peer exchange loop") // We select only the nodes discovered via DNS Discovery that support peer exchange // We assume that those peers are running peer exchange according to infra config, @@ -1021,7 +1021,7 @@ func (w *Waku) GetFilter(id string) *common.Filter { // Unsubscribe removes an installed message handler. func (w *Waku) UnsubscribeMany(ids []string) error { for _, id := range ids { - w.logger.Info("cleaning up filter", zap.String("id", id)) + w.logger.Debug("cleaning up filter", zap.String("id", id)) ok := w.filters.Uninstall(id) if !ok { w.logger.Warn("could not remove filter with id", zap.String("id", id)) @@ -1445,7 +1445,7 @@ func (w *Waku) OnNewEnvelopes(envelope *protocol.Envelope, msgType common.Messag _, err := w.add(recvMessage, processImmediately) if err != nil { - logger.Info("invalid envelope received", zap.Error(err)) + logger.Debug("invalid envelope received", zap.Error(err)) trouble = true }