Skip to content

Commit

Permalink
Clean up and improve chaincode log level messages
Browse files Browse the repository at this point in the history
Change-Id: I249a9b169070b6a36a742a83f594f7843db4b433
Signed-off-by: Will Lahti <wtlahti@us.ibm.com>
  • Loading branch information
wlahti committed Nov 18, 2016
1 parent 10f46ea commit d7df275
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion core/chaincode/chaincode_support.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func NewChaincodeSupport(chainname ChainName, getPeerEndpoint func() (*pb.PeerEn
if err == nil {
s.chaincodeLogLevel = chaincodeLogLevel.String()
} else {
chaincodeLogger.Infof("chaincode logging level %s is invalid. defaulting to %s\n", chaincodeLogLevelString, flogging.DefaultLoggingLevel().String())
chaincodeLogger.Warningf("Chaincode logging level %s is invalid; defaulting to %s", chaincodeLogLevelString, flogging.DefaultLoggingLevel().String())
s.chaincodeLogLevel = flogging.DefaultLoggingLevel().String()
}

Expand Down
15 changes: 10 additions & 5 deletions core/chaincode/shim/chaincode.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,18 @@ func SetChaincodeLoggingLevel() {
viper.SetEnvKeyReplacer(replacer)

chaincodeLogLevelString := viper.GetString("logging.chaincode")
chaincodeLogLevel, err := LogLevel(chaincodeLogLevelString)

if err == nil {
SetLoggingLevel(chaincodeLogLevel)
if chaincodeLogLevelString == "" {
shimLogLevelDefault := logging.Level(shimLoggingLevel)
chaincodeLogger.Infof("Chaincode log level not provided; defaulting to: %s", shimLogLevelDefault)
} else {
chaincodeLogger.Infof("error with chaincode log level: %s level= %s\n", err, chaincodeLogLevelString)
chaincodeLogLevel, err := LogLevel(chaincodeLogLevelString)
if err == nil {
SetLoggingLevel(chaincodeLogLevel)
} else {
chaincodeLogger.Warningf("Error: %s for chaincode log level: %s", err, chaincodeLogLevelString)
}
}

}

// StartInProc is an entry point for system chaincodes bootstrap. It is not an
Expand Down

0 comments on commit d7df275

Please sign in to comment.