From 7ea3e4b9cabd80e8b2121443be7a3cfc0b70d02d Mon Sep 17 00:00:00 2001 From: Will Lahti Date: Thu, 14 Sep 2017 12:03:53 -0400 Subject: [PATCH] [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 --- common/flogging/logging_test.go | 2 ++ peer/common/common.go | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/common/flogging/logging_test.go b/common/flogging/logging_test.go index 5584d6ddefe..4c14e52909b 100644 --- a/common/flogging/logging_test.go +++ b/common/flogging/logging_test.go @@ -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"}, diff --git a/peer/common/common.go b/peer/common/common.go index 1283cd47770..39fe66e5977 100644 --- a/peer/common/common.go +++ b/peer/common/common.go @@ -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 }