package logger

import "go.uber.org/zap"

func New(env string) *zap.Logger {
	if env == "production" {
		log, err := zap.NewProduction()
		if err == nil {
			return log
		}
	}

	config := zap.NewDevelopmentConfig()
	config.EncoderConfig.TimeKey = "ts"
	log, err := config.Build()
	if err != nil {
		return zap.Must(zap.NewDevelopment())
	}

	return log
}
