File tree Expand file tree Collapse file tree 4 files changed +14
-10
lines changed Expand file tree Collapse file tree 4 files changed +14
-10
lines changed Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ var loggingCmd = &cobra.Command{
4747 // note: for code running on the peer, this level is set during peer startup
4848 // in peer/node/start.go and can be updated dynamically using
4949 // "peer logging setlevel error <log-level>"
50- return common .SetErrorLoggingLevel ( )
50+ return common .SetLogLevelFromViper ( "error" )
5151 },
5252 Short : fmt .Sprintf ("%s specific commands." , loggingFuncName ),
5353 Long : fmt .Sprintf ("%s specific commands." , loggingFuncName ),
Original file line number Diff line number Diff line change @@ -104,12 +104,14 @@ func GetAdminClient() (pb.AdminClient, error) {
104104 return adminClient , nil
105105}
106106
107- // SetErrorLoggingLevel sets the 'error' module's logger to the value in
107+ // SetLogLevelFromViper sets the log level for ' module' logger to the value in
108108// core.yaml
109- func SetErrorLoggingLevel () error {
110- viperErrorLoggingLevel := viper .GetString ("logging.error" )
111- _ , err := flogging .SetModuleLevel ("error" , viperErrorLoggingLevel )
112-
109+ func SetLogLevelFromViper (module string ) error {
110+ var err error
111+ if module != "" {
112+ logLevelFromViper := viper .GetString ("logging." + module )
113+ _ , err = flogging .SetModuleLevel (module , logLevelFromViper )
114+ }
113115 return err
114116}
115117
Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ logging:
3636 version : warning
3737 protoutils : debug
3838 error : warning
39+ msp : warning
3940
4041 format : ' %{color}%{time:2006-01-02 15:04:05.000 MST} [%{module}] %{shortfunc} -> %{level:.4s} %{id:03x}%{color:reset} %{message}'
4142
Original file line number Diff line number Diff line change @@ -230,10 +230,11 @@ func serve(args []string) error {
230230 }()
231231 }
232232
233- // sets the logging level for the 'error' module to the default value from
234- // core.yaml. it can also be updated dynamically using
235- // "peer logging setlevel error <log-level>"
236- common .SetErrorLoggingLevel ()
233+ // sets the logging level for the 'error' and 'msp' modules to the
234+ // values from core.yaml. they can also be updated dynamically using
235+ // "peer logging setlevel <module-name> <log-level>"
236+ common .SetLogLevelFromViper ("error" )
237+ common .SetLogLevelFromViper ("msp" )
237238
238239 // Block until grpc server exits
239240 return <- serve
You can’t perform that action at this time.
0 commit comments