Skip to content

Commit 7ea3e4b

Browse files
committed
[FAB-6164] Update only modules with prefix at peer st
The peer sets the log levels for a number of logging modules at startup. It should only update the level for modules that begin with the supplied name to ensure only the expected modules are updated. Change-Id: I76f9baf8dfd556d601656798f59341f24bd88c65 Signed-off-by: Will Lahti <wtlahti@us.ibm.com>
1 parent 40e41a5 commit 7ea3e4b

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

common/flogging/logging_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ func TestSetModuleLevel(t *testing.T) {
6262
[]string{"foo/bar", "bar/baz"}, false, false},
6363
testCase{"RegexComplex", []string{"^[a-z]+\\/[a-z]+#.+$", "warning"}, []string{flogging.DefaultLevel(), flogging.DefaultLevel(), "WARNING", "WARNING", "WARNING"},
6464
[]string{"gossip/util", "orderer/util", "gossip/gossip#0.0.0.0:7051", "gossip/conn#-1", "orderer/conn#0.0.0.0:7051"}, false, false},
65+
testCase{"RegexPrefix", []string{"^test", "warning"}, []string{"WARNING", "WARNING", flogging.DefaultLevel()},
66+
[]string{"test", "test/peer", "peer/test"}, false, false},
6567
testCase{"RegexInvalid", []string{"(", "warning"}, []string{flogging.DefaultLevel()},
6668
[]string{"foo"}, false, true},
6769
testCase{"RevertLevels", []string{"revertmodule1", "warning", "revertmodule2", "debug"}, []string{"WARNING", "DEBUG", "DEBUG"},

peer/common/common.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,8 @@ func SetLogLevelFromViper(module string) error {
210210
if err != nil {
211211
return err
212212
}
213-
_, err = flogging.SetModuleLevel(module, logLevelFromViper)
213+
// only set logging modules that begin with the supplied module name here
214+
_, err = flogging.SetModuleLevel("^"+module, logLevelFromViper)
214215
return err
215216
}
216217

0 commit comments

Comments
 (0)