Skip to content

Commit

Permalink
[FAB-6315] Submodule log level override at peer start
Browse files Browse the repository at this point in the history
This CR enables overriding the default log level for a submodule
at peer start (e.g. peer/gossip). In order to set these variables
from both yaml files and environment variables, the submodule
name must be supplied using periods instead of the forward
slashes used in logging module names, hence the replacement of
periods with forward slashes.

Change-Id: I58234e6e81641709e84b8df28162539d53c7126f
Signed-off-by: Will Lahti <wtlahti@us.ibm.com>
  • Loading branch information
wlahti committed Sep 27, 2017
1 parent 9eead80 commit 907fd1f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions peer/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package common
import (
"fmt"
"os"
"strings"

"github.com/hyperledger/fabric/bccsp/factory"
"github.com/hyperledger/fabric/common/channelconfig"
Expand Down Expand Up @@ -208,6 +209,9 @@ func SetLogLevelFromViper(module string) error {
if err != nil {
return err
}
// replace period in module name with forward slash to allow override
// of logging submodules
module = strings.Replace(module, ".", "/", -1)
// only set logging modules that begin with the supplied module name here
_, err = flogging.SetModuleLevel("^"+module, logLevelFromViper)
return err
Expand Down

0 comments on commit 907fd1f

Please sign in to comment.