logger/slog: fix slog
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
34940b68d7
commit
5bec0cef03
@ -61,7 +61,6 @@ func (s *slogLogger) renameAttr(_ []string, a slog.Attr) slog.Attr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type slogLogger struct {
|
type slogLogger struct {
|
||||||
slog *slog.Logger
|
|
||||||
leveler *slog.LevelVar
|
leveler *slog.LevelVar
|
||||||
handler slog.Handler
|
handler slog.Handler
|
||||||
opts logger.Options
|
opts logger.Options
|
||||||
@ -88,8 +87,7 @@ func (s *slogLogger) Clone(opts ...logger.Option) logger.Logger {
|
|||||||
AddSource: l.opts.AddSource,
|
AddSource: l.opts.AddSource,
|
||||||
}
|
}
|
||||||
l.leveler.Set(loggerToSlogLevel(l.opts.Level))
|
l.leveler.Set(loggerToSlogLevel(l.opts.Level))
|
||||||
l.slog = slog.New(slog.NewJSONHandler(options.Out, handleOpt)).With(options.Fields...)
|
l.handler = slog.New(slog.NewJSONHandler(options.Out, handleOpt)).With(options.Fields...).Handler()
|
||||||
l.handler = l.slog.Handler()
|
|
||||||
|
|
||||||
return l
|
return l
|
||||||
}
|
}
|
||||||
@ -122,8 +120,7 @@ func (s *slogLogger) Fields(attrs ...interface{}) logger.Logger {
|
|||||||
AddSource: l.opts.AddSource,
|
AddSource: l.opts.AddSource,
|
||||||
}
|
}
|
||||||
|
|
||||||
l.slog = slog.New(slog.NewJSONHandler(l.opts.Out, handleOpt)).With(attrs...)
|
l.handler = slog.New(slog.NewJSONHandler(l.opts.Out, handleOpt)).With(attrs...).Handler()
|
||||||
l.handler = l.slog.Handler()
|
|
||||||
|
|
||||||
return l
|
return l
|
||||||
}
|
}
|
||||||
@ -146,8 +143,7 @@ func (s *slogLogger) Init(opts ...logger.Option) error {
|
|||||||
AddSource: s.opts.AddSource,
|
AddSource: s.opts.AddSource,
|
||||||
}
|
}
|
||||||
s.leveler.Set(loggerToSlogLevel(s.opts.Level))
|
s.leveler.Set(loggerToSlogLevel(s.opts.Level))
|
||||||
s.slog = slog.New(slog.NewJSONHandler(s.opts.Out, handleOpt)).With(s.opts.Fields...)
|
s.handler = slog.New(slog.NewJSONHandler(s.opts.Out, handleOpt)).With(s.opts.Fields...).Handler()
|
||||||
s.handler = s.slog.Handler()
|
|
||||||
s.mu.Unlock()
|
s.mu.Unlock()
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user