Skip to content

Commit

Permalink
chore(logging)_: default waku node logs to INFO level
Browse files Browse the repository at this point in the history
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
  • Loading branch information
osmaczko committed Dec 5, 2024
1 parent 50933aa commit c7e3c34
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
UPDATE log_config
SET
log_namespaces = 'wakunode:info'
WHERE
log_namespaces IS NULL
OR log_namespaces = '';
2 changes: 1 addition & 1 deletion wakuv2/message_publishing.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
6 changes: 3 additions & 3 deletions wakuv2/persistence/dbstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func (d *DBStore) Query(query *storepb.HistoryQuery) (*storepb.Index, []gowakuPe
start := time.Now()
defer func() {
elapsed := time.Since(start)
d.log.Info(fmt.Sprintf("Loading records from the DB took %s", elapsed))
d.log.Debug(fmt.Sprintf("Loading records from the DB took %s", elapsed))
}()

sqlQuery := `SELECT id, receiverTimestamp, senderTimestamp, contentTopic, pubsubTopic, payload, version
Expand Down Expand Up @@ -361,7 +361,7 @@ func (d *DBStore) GetAll() ([]gowakuPersistence.StoredMessage, error) {
start := time.Now()
defer func() {
elapsed := time.Since(start)
d.log.Info("loading records from the DB", zap.Duration("duration", elapsed))
d.log.Debug("loading records from the DB", zap.Duration("duration", elapsed))
}()

rows, err := d.db.Query("SELECT id, receiverTimestamp, senderTimestamp, contentTopic, pubsubTopic, payload, version FROM store_messages ORDER BY senderTimestamp ASC")
Expand All @@ -381,7 +381,7 @@ func (d *DBStore) GetAll() ([]gowakuPersistence.StoredMessage, error) {
result = append(result, record)
}

d.log.Info("DB returned records", zap.Int("count", len(result)))
d.log.Debug("DB returned records", zap.Int("count", len(result)))

err = rows.Err()
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions wakuv2/waku.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit c7e3c34

Please sign in to comment.