2022-04-28 19:24:21 -04:00
|
|
|
package log
|
|
|
|
|
|
|
|
import (
|
2022-06-12 18:46:16 -04:00
|
|
|
"github.com/go-logr/logr"
|
|
|
|
"github.com/go-logr/zapr"
|
2022-04-28 19:24:21 -04:00
|
|
|
"go.uber.org/zap"
|
|
|
|
)
|
|
|
|
|
2022-06-17 17:51:16 -04:00
|
|
|
func GetZapLogger() logr.Logger {
|
|
|
|
//json logging
|
|
|
|
cfg := zap.NewProductionConfig()
|
|
|
|
devCfg := zap.NewDevelopmentConfig()
|
|
|
|
|
|
|
|
// Readable time stamp
|
|
|
|
cfg.EncoderConfig.EncodeTime = devCfg.EncoderConfig.EncodeTime
|
|
|
|
|
|
|
|
logger, err := cfg.Build()
|
|
|
|
if err != nil {
|
|
|
|
println("unable to intialize zap log")
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return zapr.NewLogger(logger)
|
|
|
|
}
|