tss/log/log.go

42 lines
771 B
Go
Raw Normal View History

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"
)
var Logger *zap.SugaredLogger
2022-06-12 18:46:16 -04:00
var GLogr logr.Logger
2022-04-28 19:24:21 -04:00
var Debug, Info, Warn, Error, Panic func(msg string, keysAndValues ...interface{})
func init() {
2022-05-02 11:36:24 -04:00
//json logging
2022-04-28 19:24:21 -04:00
cfg := zap.NewProductionConfig()
devCfg := zap.NewDevelopmentConfig()
// Readable time stamp
cfg.EncoderConfig.EncodeTime = devCfg.EncoderConfig.EncodeTime
// Uncomment to enable debug logging
// cfg.Level = devCfg.Level
logger, err := cfg.Build()
if err != nil {
println("unable to intialize zap log")
panic(err)
}
Logger = logger.Sugar()
Debug = Logger.Debugw
Info = Logger.Infow
Warn = Logger.Warnw
Error = Logger.Errorw
Panic = Logger.Panicw
2022-06-12 18:46:16 -04:00
GLogr = zapr.NewLogger(logger)
2022-04-28 19:24:21 -04:00
}