add
This commit is contained in:
@@ -60,7 +60,11 @@ func Init() {
|
||||
zap.L().Info("✅ 日志初始化成功", zap.String("level", level.String()))
|
||||
}
|
||||
|
||||
// customTimeEncoder 自定义时间格式
|
||||
// customTimeEncoder 自定义时间格式(强制东八区)
|
||||
func customTimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder) {
|
||||
enc.AppendString(t.Format("2006-01-02 15:04:05.000"))
|
||||
// 转换为东八区(UTC+8)时间
|
||||
loc, _ := time.LoadLocation("Asia/Shanghai")
|
||||
beijingTime := t.In(loc)
|
||||
// 格式化输出
|
||||
enc.AppendString(beijingTime.Format("2006-01-02 15:04:05.000"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user