Skip to content

Commit cf17e0e

Browse files
committed
[FAB-7957] peer not respecting --logging-level
This CR ensures the peer accepts the --logging-level parameter. If it is not set, the value of CORE_LOGGING_LEVEL will be used (environment variable takes priority; otherwise, the value set in core.yaml). Change-Id: Icd7226ad09decab42ff34e78bca8b530644eb462 Signed-off-by: Will Lahti <wtlahti@us.ibm.com>
1 parent b23f581 commit cf17e0e

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

peer/main.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,16 @@ const cmdRoot = "core"
3737
var mainCmd = &cobra.Command{
3838
Use: "peer",
3939
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
40-
// check for CORE_LOGGING_LEVEL environment variable, which should override
41-
// all other log settings. otherwise, this will use the value for from
42-
// core.yaml
43-
loggingSpec := viper.GetString("logging.level")
40+
// check for --logging-level pflag first, which should override all other
41+
// log settings. if --logging-level is not set, use CORE_LOGGING_LEVEL
42+
// (environment variable takes priority; otherwise, the value set in
43+
// core.yaml)
44+
var loggingSpec string
45+
if viper.GetString("logging_level") != "" {
46+
loggingSpec = viper.GetString("logging_level")
47+
} else {
48+
loggingSpec = viper.GetString("logging.level")
49+
}
4450
flogging.InitFromSpec(loggingSpec)
4551

4652
return nil

0 commit comments

Comments
 (0)