From d7df275ad70b447358b80e08fbb800d1e453f021 Mon Sep 17 00:00:00 2001 From: Will Lahti Date: Wed, 26 Oct 2016 16:23:46 -0400 Subject: [PATCH] Clean up and improve chaincode log level messages Change-Id: I249a9b169070b6a36a742a83f594f7843db4b433 Signed-off-by: Will Lahti --- core/chaincode/chaincode_support.go | 2 +- core/chaincode/shim/chaincode.go | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/core/chaincode/chaincode_support.go b/core/chaincode/chaincode_support.go index 3324f55c030..4cebab4145b 100644 --- a/core/chaincode/chaincode_support.go +++ b/core/chaincode/chaincode_support.go @@ -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() } diff --git a/core/chaincode/shim/chaincode.go b/core/chaincode/shim/chaincode.go index a2781e0d75e..c423b45daf0 100644 --- a/core/chaincode/shim/chaincode.go +++ b/core/chaincode/shim/chaincode.go @@ -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