Skip to content

Commit 795ee80

Browse files
fix: logger sync issue
1 parent 31a0d30 commit 795ee80

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

pkg/logger/logger.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package logger
22

33
import (
4+
"errors"
5+
"log"
6+
"syscall"
7+
48
"go.uber.org/zap"
59
"go.uber.org/zap/zapcore"
610
)
@@ -52,5 +56,12 @@ func Fatal(msg string, fields ...zap.Field) {
5256
}
5357

5458
func Sync() {
55-
Logger.Sync()
56-
}
59+
if err := Logger.Sync(); err != nil {
60+
61+
var errno syscall.Errno
62+
if !errors.As(err, &errno) || (errno != syscall.EINVAL && errno != syscall.ENOTTY) {
63+
64+
log.Printf("logger sync error: %v\n", err)
65+
}
66+
}
67+
}

0 commit comments

Comments
 (0)