tss/log/log.go
2022-05-02 11:36:24 -04:00

37 lines
662 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() {
//json logging
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
}