Merge branch 'master' of github.com:dfuse-io/solana-go

This commit is contained in:
billettc 2020-11-17 07:15:12 -05:00
commit ff602fdde9
5 changed files with 15 additions and 20 deletions

View File

@ -15,13 +15,11 @@
package rpc package rpc
import ( import (
"os"
"github.com/dfuse-io/logging" "github.com/dfuse-io/logging"
"go.uber.org/zap" "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 var zlog *zap.Logger
func init() { func init() {

View File

@ -89,11 +89,12 @@ func (c *Client) handleMessage(message []byte) {
func (c *Client) handleNewSubscriptionMessage(requestID, subID uint64) { func (c *Client) handleNewSubscriptionMessage(requestID, subID uint64) {
c.lock.Lock() c.lock.Lock()
defer c.lock.Unlock() defer c.lock.Unlock()
if traceEnabled {
zlog.Info("received new subscription message", zlog.Debug("received new subscription message",
zap.Uint64("message_id", requestID), zap.Uint64("message_id", requestID),
zap.Uint64("subscription_id", subID), zap.Uint64("subscription_id", subID),
) )
}
callBack, found := c.subscriptionByRequestID[requestID] callBack, found := c.subscriptionByRequestID[requestID]
if !found { if !found {
zlog.Error("cannot find websocket message handler for a new stream.... this should not happen", zlog.Error("cannot find websocket message handler for a new stream.... this should not happen",
@ -107,9 +108,11 @@ func (c *Client) handleNewSubscriptionMessage(requestID, subID uint64) {
} }
func (c *Client) handleSubscriptionMessage(subID uint64, message []byte) { func (c *Client) handleSubscriptionMessage(subID uint64, message []byte) {
zlog.Debug("received subscription message", if traceEnabled {
zap.Uint64("subscription_id", subID), zlog.Debug("received subscription message",
) zap.Uint64("subscription_id", subID),
)
}
c.lock.RLock() c.lock.RLock()
sub, found := c.subscriptionByWSSubID[subID] sub, found := c.subscriptionByWSSubID[subID]

View File

@ -15,14 +15,12 @@
package ws package ws
import ( import (
"os"
"github.com/dfuse-io/logging" "github.com/dfuse-io/logging"
"go.uber.org/zap" "go.uber.org/zap"
) )
var traceEnabled = os.Getenv("TRACE") == "true"
var zlog *zap.Logger var zlog *zap.Logger
var traceEnabled = logging.IsTraceEnabled("solana-go", "github.com/dfuse-io/solana-go/rpc/ws")
func init() { func init() {
logging.Register("github.com/dfuse-io/solana-go/rpc/ws", &zlog) logging.Register("github.com/dfuse-io/solana-go/rpc/ws", &zlog)

View File

@ -15,14 +15,12 @@
package serum package serum
import ( import (
"os"
"github.com/dfuse-io/logging" "github.com/dfuse-io/logging"
"go.uber.org/zap" "go.uber.org/zap"
) )
var traceEnabled = os.Getenv("TRACE") != ""
var zlog = zap.NewNop() var zlog = zap.NewNop()
var traceEnabled = logging.IsTraceEnabled("solana-go", "github.com/dfuse-io/solana-go/serum")
func init() { func init() {
logging.Register("github.com/dfuse-io/solana-go/serum", &zlog) logging.Register("github.com/dfuse-io/solana-go/serum", &zlog)

View File

@ -15,13 +15,11 @@
package system package system
import ( import (
"os"
"github.com/dfuse-io/logging" "github.com/dfuse-io/logging"
"go.uber.org/zap" "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() var zlog = zap.NewNop()
func init() { func init() {