Skip to content

Commit 98c2710

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

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
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)

server/main.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@ var (
2121
)
2222

2323
func main() {
24-
defer func() {
25-
if r := recover(); r != nil {
26-
fmt.Printf("panic: %v", r)
27-
}
28-
fmt.Println("=== app exit")
29-
}()
3024
fmt.Println("Starting ceramicraft-user-mservice...")
3125
config.Init()
3226
log.InitLogger()

0 commit comments

Comments
 (0)