From 5bec0cef034a61d2c29683dd8ba15289959ae7bc Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Thu, 7 Mar 2024 08:19:14 +0300 Subject: [PATCH] logger/slog: fix slog Signed-off-by: Vasiliy Tolstov --- logger/slog/slog.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/logger/slog/slog.go b/logger/slog/slog.go index 71e335d2..3c699cff 100644 --- a/logger/slog/slog.go +++ b/logger/slog/slog.go @@ -61,7 +61,6 @@ func (s *slogLogger) renameAttr(_ []string, a slog.Attr) slog.Attr { } type slogLogger struct { - slog *slog.Logger leveler *slog.LevelVar handler slog.Handler opts logger.Options @@ -88,8 +87,7 @@ func (s *slogLogger) Clone(opts ...logger.Option) logger.Logger { AddSource: l.opts.AddSource, } l.leveler.Set(loggerToSlogLevel(l.opts.Level)) - l.slog = slog.New(slog.NewJSONHandler(options.Out, handleOpt)).With(options.Fields...) - l.handler = l.slog.Handler() + l.handler = slog.New(slog.NewJSONHandler(options.Out, handleOpt)).With(options.Fields...).Handler() return l } @@ -122,8 +120,7 @@ func (s *slogLogger) Fields(attrs ...interface{}) logger.Logger { AddSource: l.opts.AddSource, } - l.slog = slog.New(slog.NewJSONHandler(l.opts.Out, handleOpt)).With(attrs...) - l.handler = l.slog.Handler() + l.handler = slog.New(slog.NewJSONHandler(l.opts.Out, handleOpt)).With(attrs...).Handler() return l } @@ -146,8 +143,7 @@ func (s *slogLogger) Init(opts ...logger.Option) error { AddSource: s.opts.AddSource, } s.leveler.Set(loggerToSlogLevel(s.opts.Level)) - s.slog = slog.New(slog.NewJSONHandler(s.opts.Out, handleOpt)).With(s.opts.Fields...) - s.handler = s.slog.Handler() + s.handler = slog.New(slog.NewJSONHandler(s.opts.Out, handleOpt)).With(s.opts.Fields...).Handler() s.mu.Unlock() return nil -- 2.45.2