Skip to content

Commit

Permalink
[FAB-6041] Fabric-SDK-Go doesn't log properly
Browse files Browse the repository at this point in the history
           Investigate issue for client logging fixed

Change-Id: I21d24d844dbc482edc1dd0eb04d37877953d933e
Signed-off-by: Baha Shaaban <baha.shaaban@securekey.com>
  • Loading branch information
Baha Shaaban committed Sep 6, 2017
1 parent 4213e7e commit 74e5fa8
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ func InitConfigWithCmdRoot(configFile string, cmdRootPrefix string) (*Config, er
myViper.AutomaticEnv()
replacer := strings.NewReplacer(".", "_")
myViper.SetEnvKeyReplacer(replacer)

if configFile != "" {
// create new viper
myViper.SetConfigFile(configFile)
Expand All @@ -69,22 +68,20 @@ func InitConfigWithCmdRoot(configFile string, cmdRootPrefix string) (*Config, er
return nil, fmt.Errorf("Fatal error config file: %v", err)
}
}
log.Debug(myViper.GetString("client.fabricCA.serverURL"))
backend := logging.NewLogBackend(os.Stderr, "", 0)
backendFormatter := logging.NewBackendFormatter(backend, format)

loggingLevelString := myViper.GetString("client.logging.level")
logLevel := logging.INFO
if loggingLevelString != "" {
log.Infof("fabric_sdk_go Logging level: %v", loggingLevelString)
log.Infof("fabric_sdk_go Logging level from the config: %v", loggingLevelString)
var err error
logLevel, err = logging.LogLevel(loggingLevelString)
if err != nil {
panic(err)
}
}
logging.SetBackend(backendFormatter).SetLevel(logging.Level(logLevel), "fabric_sdk_go")
logging.SetLevel(logging.Level(logLevel), "fabric_sdk_go")

log.Infof("fabric_sdk_go Logging level is finally set to: %s", logging.GetLevel("fabric_sdk_go"))
return &Config{tlsCertPool: x509.NewCertPool()}, nil
}

Expand Down

0 comments on commit 74e5fa8

Please sign in to comment.