Skip to content

Commit eaf52b3

Browse files
committedSep 28, 2017
[FAB-6316]Override peer/gossip log level at peer start
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 <wtlahti@us.ibm.com>
1 parent c0aa4a7 commit eaf52b3

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed
 

‎peer/common/common_test.go

+5
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,11 @@ func TestSetLogLevelFromViper(t *testing.T) {
150150
args: args{module: "policies"},
151151
wantErr: false,
152152
},
153+
{
154+
name: "Valid module name",
155+
args: args{module: "peer.gossip"},
156+
wantErr: false,
157+
},
153158
}
154159
for _, tt := range tests {
155160
t.Run(tt.name, func(t *testing.T) {

‎peer/gossip/mcs.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,12 @@ func (s *mspMessageCryptoService) VerifyBlock(chainID common.ChainID, seqNum uin
167167
return fmt.Errorf("Could not acquire policy manager for channel %s", channelID)
168168
}
169169
// ok is true if it was the manager requested, or false if it is the default manager
170-
mcsLogger.Debugf("Got policy manager for channel [%s] with flag [%s]", channelID, ok)
170+
mcsLogger.Debugf("Got policy manager for channel [%s] with flag [%t]", channelID, ok)
171171

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

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

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

250250
return policy.Evaluate(
251251
[]*pcommon.SignedData{{

‎peer/node/start.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ func serve(args []string) error {
282282

283283
// set the logging level for specific modules defined via environment
284284
// variables or core.yaml
285-
overrideLogModules := []string{"msp", "gossip", "ledger", "cauthdsl", "policies", "grpc"}
285+
overrideLogModules := []string{"msp", "gossip", "ledger", "cauthdsl", "policies", "grpc", "peer.gossip"}
286286
for _, module := range overrideLogModules {
287287
err = common.SetLogLevelFromViper(module)
288288
if err != nil {

‎sampleconfig/core.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,12 @@ logging:
4747
# time.
4848
cauthdsl: warning
4949
gossip: warning
50+
grpc: error
5051
ledger: info
5152
msp: warning
5253
policies: warning
53-
grpc: error
54+
peer:
55+
gossip: warning
5456

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

0 commit comments

Comments
 (0)