func TestGetModuleLoggingLevelDefault(t *testing.T) { level, _ := flogging.GetModuleLogLevel("peer") // peer should be using the default log level at this point if level != "INFO" { t.FailNow() } }
func TestGetModuleLoggingLevelInvalid(t *testing.T) { flogging.SetModuleLogLevel("peer", "invalid") level, _ := flogging.GetModuleLogLevel("peer") // ensure that the log level didn't change after invalid log level specified if level != "DEBUG" { t.FailNow() } }
func TestGetModuleLoggingLevelDebug(t *testing.T) { flogging.SetModuleLogLevel("peer", "DEBUG") level, _ := flogging.GetModuleLogLevel("peer") // ensure that the log level has changed to debug if level != "DEBUG" { t.FailNow() } }
// Message returns the corresponding error message for this error in default // language. // TODO - figure out the best way to read in system language instead of using // hard-coded default language func (h *hlError) Message() string { // initialize logging level for errors from core.yaml. it can also be set // for code running on the peer dynamically via CLI using // "peer logging setlevel error <log-level>" errorLogLevelString, _ := flogging.GetModuleLogLevel("error") if errorLogLevelString == logging.DEBUG.String() { messageWithCallStack := fmt.Sprintf(emap[fmt.Sprintf("%s", h.componentcode)][fmt.Sprintf("%s", h.reasoncode)][language], h.args...) + "\n" + h.GetStack() return messageWithCallStack } return fmt.Sprintf(emap[fmt.Sprintf("%s", h.componentcode)][fmt.Sprintf("%s", h.reasoncode)][language], h.args...) }
// GetModuleLogLevel gets the current logging level for the specified module func (*ServerAdmin) GetModuleLogLevel(ctx context.Context, request *pb.LogLevelRequest) (*pb.LogLevelResponse, error) { logLevelString, err := flogging.GetModuleLogLevel(request.LogModule) logResponse := &pb.LogLevelResponse{LogModule: request.LogModule, LogLevel: logLevelString} return logResponse, err }