portal/logger/logger.go

31 lines
386 B
Go
Raw Normal View History

package logger
import (
2023-06-06 20:37:22 +00:00
"github.com/spf13/viper"
"go.uber.org/zap"
"log"
)
var logger *zap.Logger
func Init() {
2023-06-06 20:37:22 +00:00
var newLogger *zap.Logger
var err error
if viper.GetBool("debug") {
newLogger, err = zap.NewDevelopment()
} else {
newLogger, err = zap.NewProduction()
}
if err != nil {
log.Fatal(err)
}
logger = newLogger
}
func Get() *zap.Logger {
return logger
}