added a bit of zap logging
Some checks failed
Build and Push Docker Image / Build image (push) Failing after 58s
Some checks failed
Build and Push Docker Image / Build image (push) Failing after 58s
This commit is contained in:
26
logger/logger.go
Normal file
26
logger/logger.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package logger
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"go.uber.org/zap"
|
||||
"go.uber.org/zap/zapcore"
|
||||
)
|
||||
|
||||
var Logger *zap.Logger
|
||||
|
||||
func init() {
|
||||
var cfg zap.Config
|
||||
if os.Getenv("DEBUG") == "true" {
|
||||
cfg = zap.NewDevelopmentConfig()
|
||||
} else {
|
||||
cfg = zap.NewProductionConfig()
|
||||
}
|
||||
cfg.EncoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder
|
||||
var err error
|
||||
Logger, err = cfg.Build()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer Logger.Sync() // flushes buffer, if any
|
||||
}
|
||||
Reference in New Issue
Block a user