Skip to content

Commit

Permalink
[FAB-7957] peer not respecting --logging-level
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
wlahti committed Jan 29, 2018
1 parent b23f581 commit cf17e0e
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions peer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,16 @@ const cmdRoot = "core"
var mainCmd = &cobra.Command{
Use: "peer",
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
// check for CORE_LOGGING_LEVEL environment variable, which should override
// all other log settings. otherwise, this will use the value for from
// core.yaml
loggingSpec := viper.GetString("logging.level")
// check for --logging-level pflag first, which should override all other
// log settings. if --logging-level is not set, use CORE_LOGGING_LEVEL
// (environment variable takes priority; otherwise, the value set in
// core.yaml)
var loggingSpec string
if viper.GetString("logging_level") != "" {
loggingSpec = viper.GetString("logging_level")
} else {
loggingSpec = viper.GetString("logging.level")
}
flogging.InitFromSpec(loggingSpec)

return nil
Expand Down

0 comments on commit cf17e0e

Please sign in to comment.