From b781f1bfc785efa7f5f8c1a5e53780c516bca1ab Mon Sep 17 00:00:00 2001 From: Julien Cassis Date: Mon, 16 Nov 2020 13:31:05 -0500 Subject: [PATCH 1/2] downgrade logger --- rpc/ws/client.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/rpc/ws/client.go b/rpc/ws/client.go index 52ec278..46c3605 100644 --- a/rpc/ws/client.go +++ b/rpc/ws/client.go @@ -89,11 +89,12 @@ func (c *Client) handleMessage(message []byte) { func (c *Client) handleNewSubscriptionMessage(requestID, subID uint64) { c.lock.Lock() defer c.lock.Unlock() - - zlog.Info("received new subscription message", - zap.Uint64("message_id", requestID), - zap.Uint64("subscription_id", subID), - ) + if traceEnabled { + zlog.Debug("received new subscription message", + zap.Uint64("message_id", requestID), + zap.Uint64("subscription_id", subID), + ) + } callBack, found := c.subscriptionByRequestID[requestID] if !found { zlog.Error("cannot find websocket message handler for a new stream.... this should not happen", From ec87d9570afb0c2e2f0c12109b50bec2dc7791f1 Mon Sep 17 00:00:00 2001 From: Julien Cassis Date: Mon, 16 Nov 2020 13:39:07 -0500 Subject: [PATCH 2/2] move traceEnabled to logging.IsTraceEnabled --- rpc/logging.go | 4 +--- rpc/ws/client.go | 8 +++++--- rpc/ws/logging.go | 4 +--- serum/logging.go | 4 +--- system/logging.go | 4 +--- 5 files changed, 9 insertions(+), 15 deletions(-) diff --git a/rpc/logging.go b/rpc/logging.go index 215bb86..b7626ce 100644 --- a/rpc/logging.go +++ b/rpc/logging.go @@ -15,13 +15,11 @@ package rpc import ( - "os" - "github.com/dfuse-io/logging" "go.uber.org/zap" ) -var traceEnabled = os.Getenv("TRACE") == "true" +var traceEnabled = logging.IsTraceEnabled("solana-go", "github.com/dfuse-io/solana-go/rpc") var zlog *zap.Logger func init() { diff --git a/rpc/ws/client.go b/rpc/ws/client.go index 46c3605..fa30083 100644 --- a/rpc/ws/client.go +++ b/rpc/ws/client.go @@ -108,9 +108,11 @@ func (c *Client) handleNewSubscriptionMessage(requestID, subID uint64) { } func (c *Client) handleSubscriptionMessage(subID uint64, message []byte) { - zlog.Debug("received subscription message", - zap.Uint64("subscription_id", subID), - ) + if traceEnabled { + zlog.Debug("received subscription message", + zap.Uint64("subscription_id", subID), + ) + } c.lock.RLock() sub, found := c.subscriptionByWSSubID[subID] diff --git a/rpc/ws/logging.go b/rpc/ws/logging.go index 66457f2..e2eac10 100644 --- a/rpc/ws/logging.go +++ b/rpc/ws/logging.go @@ -15,14 +15,12 @@ package ws import ( - "os" - "github.com/dfuse-io/logging" "go.uber.org/zap" ) -var traceEnabled = os.Getenv("TRACE") == "true" var zlog *zap.Logger +var traceEnabled = logging.IsTraceEnabled("solana-go", "github.com/dfuse-io/solana-go/rpc/ws") func init() { logging.Register("github.com/dfuse-io/solana-go/rpc/ws", &zlog) diff --git a/serum/logging.go b/serum/logging.go index 5bfafa3..b2767eb 100644 --- a/serum/logging.go +++ b/serum/logging.go @@ -15,14 +15,12 @@ package serum import ( - "os" - "github.com/dfuse-io/logging" "go.uber.org/zap" ) -var traceEnabled = os.Getenv("TRACE") != "" var zlog = zap.NewNop() +var traceEnabled = logging.IsTraceEnabled("solana-go", "github.com/dfuse-io/solana-go/serum") func init() { logging.Register("github.com/dfuse-io/solana-go/serum", &zlog) diff --git a/system/logging.go b/system/logging.go index 227a2c8..42cc698 100644 --- a/system/logging.go +++ b/system/logging.go @@ -15,13 +15,11 @@ package system import ( - "os" - "github.com/dfuse-io/logging" "go.uber.org/zap" ) -var traceEnabled = os.Getenv("TRACE") != "" +var traceEnabled = logging.IsTraceEnabled("solana-go", "github.com/dfuse-io/solana-go/system") var zlog = zap.NewNop() func init() {