fixed struct alignment && refactor linter
This commit is contained in:
@@ -46,11 +46,11 @@ func (h *wrapper) Handle(ctx context.Context, rec slog.Record) error {
|
||||
}
|
||||
|
||||
func (h *wrapper) WithAttrs(attrs []slog.Attr) slog.Handler {
|
||||
return h.WithAttrs(attrs)
|
||||
return h.h.WithAttrs(attrs)
|
||||
}
|
||||
|
||||
func (h *wrapper) WithGroup(name string) slog.Handler {
|
||||
return h.WithGroup(name)
|
||||
return h.h.WithGroup(name)
|
||||
}
|
||||
|
||||
func (s *slogLogger) renameAttr(_ []string, a slog.Attr) slog.Attr {
|
||||
@@ -89,7 +89,6 @@ func (s *slogLogger) renameAttr(_ []string, a slog.Attr) slog.Attr {
|
||||
}
|
||||
|
||||
type slogLogger struct {
|
||||
leveler *slog.LevelVar
|
||||
handler *wrapper
|
||||
opts logger.Options
|
||||
mu sync.RWMutex
|
||||
@@ -318,7 +317,7 @@ func (s *slogLogger) argsAttrs(args []interface{}) ([]slog.Attr, error) {
|
||||
case string:
|
||||
if idx+1 < len(args) {
|
||||
attrs = append(attrs, slog.Any(arg, args[idx+1]))
|
||||
idx += 1
|
||||
idx++
|
||||
} else {
|
||||
attrs = append(attrs, slog.String(badKey, arg))
|
||||
}
|
||||
|
||||
@@ -10,9 +10,8 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"go.unistack.org/micro/v3/metadata"
|
||||
|
||||
"go.unistack.org/micro/v3/logger"
|
||||
"go.unistack.org/micro/v3/metadata"
|
||||
)
|
||||
|
||||
func TestWithAddFields(t *testing.T) {
|
||||
@@ -115,7 +114,7 @@ func TestErrorf(t *testing.T) {
|
||||
|
||||
buf := bytes.NewBuffer(nil)
|
||||
l := NewLogger(logger.WithLevel(logger.ErrorLevel), logger.WithOutput(buf), logger.WithAddStacktrace(true))
|
||||
if err := l.Init(logger.WithContextAttrFuncs(func(ctx context.Context) []interface{} {
|
||||
if err := l.Init(logger.WithContextAttrFuncs(func(_ context.Context) []interface{} {
|
||||
return nil
|
||||
})); err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
Reference in New Issue
Block a user