From ed416fec2e7f6fac52dcc5502a780c2d038b2a5c Mon Sep 17 00:00:00 2001 From: Injun Song Date: Mon, 8 Jul 2024 18:53:20 +0900 Subject: [PATCH] fix(logger): no overriding custom zap logger options This PR ensures that custom options are preserved without being overridden by recommended options. --- pkg/util/log/logger.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/util/log/logger.go b/pkg/util/log/logger.go index f07af602b..4ce5e91d2 100644 --- a/pkg/util/log/logger.go +++ b/pkg/util/log/logger.go @@ -2,6 +2,7 @@ package log import ( "os" + "slices" "time" "go.uber.org/zap" @@ -54,10 +55,10 @@ func New(opts ...Option) (*zap.Logger, error) { core := zapcore.NewCore(encoder, syncer, level) // Recommended zap.Option - zapOpts := append(cfg.zapOpts, + zapOpts := slices.Concat([]zap.Option{ zap.AddCaller(), zap.AddStacktrace(zap.ErrorLevel), - ) + }, cfg.zapOpts) // Sampler if cfg.zapSampling != nil {