Skip to content

Commit 17a26da

Browse files
committed
[FAB-3445] unrecognized characters in the gossip log
Some of our modules print funny characters such as: 2017-04-27 08:21:33.648 UTC [flogging] setModuleLevel -> DEBU 2eea Module 'gossip/gossip#^>+�>�Q� �N�5�W"���?�xʷ��?J This is caused because we have (for testing) module names that consist of both the module itself + a descriptor for the peer instance, since all instances run in the same process in unit tests. In some modules the descriptor is the PKI-ID of the peer, which in tests its simply the endpoint of the peer, but in production this is the hash of the cert --> which isn't ASCII. I adjusted our logging config to use only the module in production, and use the existing flow only in test code, where it belongs. Change-Id: Idc3ec6a4b9223d1506873a3af7210bf1271654f2 Signed-off-by: Yacov Manevich <[email protected]>
1 parent eff8380 commit 17a26da

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

gossip/gossip/chanstate.go

-5
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626
"github.com/hyperledger/fabric/gossip/common"
2727
"github.com/hyperledger/fabric/gossip/discovery"
2828
"github.com/hyperledger/fabric/gossip/gossip/channel"
29-
"github.com/hyperledger/fabric/gossip/util"
3029
proto "github.com/hyperledger/fabric/protos/gossip"
3130
)
3231

@@ -37,10 +36,6 @@ type channelState struct {
3736
g *gossipServiceImpl
3837
}
3938

40-
func init() {
41-
util.SetupTestLogging()
42-
}
43-
4439
func (cs *channelState) stop() {
4540
if cs.isStopping() {
4641
return

gossip/util/logging.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,14 @@ const (
3838

3939
var loggersByModules = make(map[string]*logging.Logger)
4040
var lock = sync.Mutex{}
41+
var testMode bool
4142

4243
// defaultTestSpec is the default logging level for gossip tests
4344
var defaultTestSpec = "WARNING"
4445

4546
// GetLogger returns a logger for given gossip module and peerID
4647
func GetLogger(module string, peerID string) *logging.Logger {
47-
if peerID != "" {
48+
if peerID != "" && testMode {
4849
module = module + "#" + peerID
4950
}
5051

@@ -63,5 +64,6 @@ func GetLogger(module string, peerID string) *logging.Logger {
6364

6465
// SetupTestLogging sets the default log levels for gossip unit tests
6566
func SetupTestLogging() {
67+
testMode = true
6668
flogging.InitFromSpec(defaultTestSpec)
6769
}

0 commit comments

Comments
 (0)