tss/log/log.go
2022-04-28 19:24:21 -04:00

36 lines
646 B
Go

package log
import (
"go.uber.org/zap"
)
var Logger *zap.SugaredLogger
var Debug, Info, Warn, Error, Panic func(msg string, keysAndValues ...interface{})
func init() {
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
}