Skip to content

Commit

Permalink
[FAB-6164] Update only modules with prefix at peer st
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
wlahti committed Sep 14, 2017
1 parent 40e41a5 commit 7ea3e4b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions common/flogging/logging_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ func TestSetModuleLevel(t *testing.T) {
[]string{"foo/bar", "bar/baz"}, false, false},
testCase{"RegexComplex", []string{"^[a-z]+\\/[a-z]+#.+$", "warning"}, []string{flogging.DefaultLevel(), flogging.DefaultLevel(), "WARNING", "WARNING", "WARNING"},
[]string{"gossip/util", "orderer/util", "gossip/gossip#0.0.0.0:7051", "gossip/conn#-1", "orderer/conn#0.0.0.0:7051"}, false, false},
testCase{"RegexPrefix", []string{"^test", "warning"}, []string{"WARNING", "WARNING", flogging.DefaultLevel()},
[]string{"test", "test/peer", "peer/test"}, false, false},
testCase{"RegexInvalid", []string{"(", "warning"}, []string{flogging.DefaultLevel()},
[]string{"foo"}, false, true},
testCase{"RevertLevels", []string{"revertmodule1", "warning", "revertmodule2", "debug"}, []string{"WARNING", "DEBUG", "DEBUG"},
Expand Down
3 changes: 2 additions & 1 deletion peer/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ func SetLogLevelFromViper(module string) error {
if err != nil {
return err
}
_, err = flogging.SetModuleLevel(module, logLevelFromViper)
// only set logging modules that begin with the supplied module name here
_, err = flogging.SetModuleLevel("^"+module, logLevelFromViper)
return err
}

Expand Down

0 comments on commit 7ea3e4b

Please sign in to comment.