diff --git a/gossip/gossip/chanstate.go b/gossip/gossip/chanstate.go index d0c112a97bb..8f7f528508a 100644 --- a/gossip/gossip/chanstate.go +++ b/gossip/gossip/chanstate.go @@ -26,7 +26,6 @@ import ( "github.com/hyperledger/fabric/gossip/common" "github.com/hyperledger/fabric/gossip/discovery" "github.com/hyperledger/fabric/gossip/gossip/channel" - "github.com/hyperledger/fabric/gossip/util" proto "github.com/hyperledger/fabric/protos/gossip" ) @@ -37,10 +36,6 @@ type channelState struct { g *gossipServiceImpl } -func init() { - util.SetupTestLogging() -} - func (cs *channelState) stop() { if cs.isStopping() { return diff --git a/gossip/util/logging.go b/gossip/util/logging.go index a908247d743..8c8ecc3acff 100644 --- a/gossip/util/logging.go +++ b/gossip/util/logging.go @@ -38,13 +38,14 @@ const ( var loggersByModules = make(map[string]*logging.Logger) var lock = sync.Mutex{} +var testMode bool // defaultTestSpec is the default logging level for gossip tests var defaultTestSpec = "WARNING" // GetLogger returns a logger for given gossip module and peerID func GetLogger(module string, peerID string) *logging.Logger { - if peerID != "" { + if peerID != "" && testMode { module = module + "#" + peerID } @@ -63,5 +64,6 @@ func GetLogger(module string, peerID string) *logging.Logger { // SetupTestLogging sets the default log levels for gossip unit tests func SetupTestLogging() { + testMode = true flogging.InitFromSpec(defaultTestSpec) }