Skip to content

Commit bf938ed

Browse files
committed
fix: [KAN-128] fix log timezone
1 parent 7753380 commit bf938ed

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

server/log/logger.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ func getLogLevel() zapcore.Level {
3737
func getEncoder() zapcore.Encoder {
3838
encoderConfig := zap.NewProductionEncoderConfig()
3939
encoderConfig.EncodeTime = func(t time.Time, enc zapcore.PrimitiveArrayEncoder) {
40-
enc.AppendString(t.Local().Format("2006-01-02 15:04:05"))
40+
location, err := time.LoadLocation("Asia/Singapore")
41+
if err != nil {
42+
location = time.Local
43+
}
44+
enc.AppendString(t.In(location).Format("2006-01-02 15:04:05"))
4145
}
4246
encoderConfig.EncodeLevel = zapcore.CapitalLevelEncoder
4347
return zapcore.NewConsoleEncoder(encoderConfig)

0 commit comments

Comments
 (0)