diff --git a/config/config.go b/config/config.go index d4397d5..f943935 100644 --- a/config/config.go +++ b/config/config.go @@ -52,18 +52,18 @@ func ErrorStatus(message string, httpStatusCode int, w http.ResponseWriter, err w.WriteHeader(httpStatusCode) b, _ := json.Marshal(models.ErrorMessageResponse{Response: models.MessageError{Message: message, Error: err.Error()}}) w.Write(b) - return } // setLogger is a helper function to set the Logger based on the environment func setLogger(env string) (*zap.Logger, error) { - if env == "production" { + switch env { + case "production": return zap.NewProduction() - } else if env == "development" { + case "development": return zap.NewDevelopment() - } else if env == "local" { + case "local": return zap.NewExample(), nil - } else { - return zap.NewExample(), fmt.Errorf("cannot find ENV car so defaulting to debug level logging") + default: + return zap.NewExample(), fmt.Errorf("cannon find ENV car so defaulting to debug logging") } }