Skip to content

Commit

Permalink
[FAB-6316]Override peer/gossip log level at peer start
Browse files Browse the repository at this point in the history
This CR overrides the log level of all loggers that begin with
"peer/gossip" at peer startup. It also cleans up the output
of a few logging messages so that they correctly print the boolean
value.

Change-Id: I9b954aa5bd852aed2c06f98183b79b4b68ff0b4c
Signed-off-by: Will Lahti <[email protected]>
  • Loading branch information
wlahti committed Sep 28, 2017
1 parent c0aa4a7 commit eaf52b3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
5 changes: 5 additions & 0 deletions peer/common/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ func TestSetLogLevelFromViper(t *testing.T) {
args: args{module: "policies"},
wantErr: false,
},
{
name: "Valid module name",
args: args{module: "peer.gossip"},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
8 changes: 4 additions & 4 deletions peer/gossip/mcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,12 @@ func (s *mspMessageCryptoService) VerifyBlock(chainID common.ChainID, seqNum uin
return fmt.Errorf("Could not acquire policy manager for channel %s", channelID)
}
// ok is true if it was the manager requested, or false if it is the default manager
mcsLogger.Debugf("Got policy manager for channel [%s] with flag [%s]", channelID, ok)
mcsLogger.Debugf("Got policy manager for channel [%s] with flag [%t]", channelID, ok)

// Get block validation policy
policy, ok := cpm.GetPolicy(policies.BlockValidation)
// ok is true if it was the policy requested, or false if it is the default policy
mcsLogger.Debugf("Got block validation policy for channel [%s] with flag [%s]", channelID, ok)
mcsLogger.Debugf("Got block validation policy for channel [%s] with flag [%t]", channelID, ok)

// - Prepare SignedData
signatureSet := []*pcommon.SignedData{}
Expand Down Expand Up @@ -241,11 +241,11 @@ func (s *mspMessageCryptoService) VerifyByChannel(chainID common.ChainID, peerId
if cpm == nil {
return fmt.Errorf("Could not acquire policy manager for channel %s", string(chainID))
}
mcsLogger.Debugf("Got policy manager for channel [%s] with flag [%s]", string(chainID), flag)
mcsLogger.Debugf("Got policy manager for channel [%s] with flag [%t]", string(chainID), flag)

// Get channel reader policy
policy, flag := cpm.GetPolicy(policies.ChannelApplicationReaders)
mcsLogger.Debugf("Got reader policy for channel [%s] with flag [%s]", string(chainID), flag)
mcsLogger.Debugf("Got reader policy for channel [%s] with flag [%t]", string(chainID), flag)

return policy.Evaluate(
[]*pcommon.SignedData{{
Expand Down
2 changes: 1 addition & 1 deletion peer/node/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ func serve(args []string) error {

// set the logging level for specific modules defined via environment
// variables or core.yaml
overrideLogModules := []string{"msp", "gossip", "ledger", "cauthdsl", "policies", "grpc"}
overrideLogModules := []string{"msp", "gossip", "ledger", "cauthdsl", "policies", "grpc", "peer.gossip"}
for _, module := range overrideLogModules {
err = common.SetLogLevelFromViper(module)
if err != nil {
Expand Down
4 changes: 3 additions & 1 deletion sampleconfig/core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@ logging:
# time.
cauthdsl: warning
gossip: warning
grpc: error
ledger: info
msp: warning
policies: warning
grpc: error
peer:
gossip: warning

# Message format for the peer logs
format: '%{color}%{time:2006-01-02 15:04:05.000 MST} [%{module}] %{shortfunc} -> %{level:.4s} %{id:03x}%{color:reset} %{message}'
Expand Down

0 comments on commit eaf52b3

Please sign in to comment.