From 5f9fdadbbadc820cb49eda5c8db826b0fa9385fc Mon Sep 17 00:00:00 2001 From: ispiroglu Date: Sat, 31 Aug 2024 13:59:14 +0300 Subject: [PATCH 1/2] fix(logger): ignore known uber-zap error on sync method See: https://github.com/uber-go/zap/issues/991 --- logger/logger.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/logger/logger.go b/logger/logger.go index db94442..4457ff9 100644 --- a/logger/logger.go +++ b/logger/logger.go @@ -3,6 +3,8 @@ package logger import ( "context" "errors" + "io/fs" + "syscall" "github.com/Trendyol/chaki/util/appctx" "go.uber.org/zap" @@ -45,7 +47,14 @@ func New() *zap.Logger { } func Sync() error { - return New().Sync() + err := New().Sync() + + var pathErr *fs.PathError + if errors.Is(err, syscall.ENOTTY) || errors.As(err, &pathErr) { + return nil + } + + return err } func From(ctx context.Context) *zap.Logger { From 1857745d5ba3be64d19d1b138397ef9a97b15ec2 Mon Sep 17 00:00:00 2001 From: ispiroglu Date: Sat, 31 Aug 2024 14:00:12 +0300 Subject: [PATCH 2/2] fix: run fieldalignment tool and fix structs to reduce mem usage --- option.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/option.go b/option.go index 2d590e0..0ce1c53 100644 --- a/option.go +++ b/option.go @@ -5,14 +5,14 @@ import ( ) type configOptions struct { - disabled bool - path string referencePaths map[string]string + path string + disabled bool } type options struct { - timeout time.Duration configOptions configOptions + timeout time.Duration } func getOptions(opt ...Option) *options {