Skip to content

Commit

Permalink
move traceEnabled to logging.IsTraceEnabled
Browse files Browse the repository at this point in the history
  • Loading branch information
jubeless committed Nov 16, 2020
1 parent b781f1b commit ec87d95
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 15 deletions.
4 changes: 1 addition & 3 deletions rpc/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
8 changes: 5 additions & 3 deletions rpc/ws/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 1 addition & 3 deletions rpc/ws/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 1 addition & 3 deletions serum/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 1 addition & 3 deletions system/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit ec87d95

Please sign in to comment.