首次提交
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
package logger
|
||||
|
||||
import (
|
||||
"go.uber.org/zap"
|
||||
"go.uber.org/zap/zapcore"
|
||||
)
|
||||
|
||||
func New(env string) (*zap.Logger, error) {
|
||||
var cfg zap.Config
|
||||
if env == "production" {
|
||||
cfg = zap.NewProductionConfig()
|
||||
cfg.EncoderConfig.TimeKey = "time"
|
||||
cfg.EncoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder
|
||||
} else {
|
||||
cfg = zap.NewDevelopmentConfig()
|
||||
cfg.EncoderConfig.EncodeLevel = zapcore.CapitalColorLevelEncoder
|
||||
}
|
||||
return cfg.Build()
|
||||
}
|
||||
Reference in New Issue
Block a user