Skip to content

Commit 63b21e9

Browse files
#50 added support for slog.Group
1 parent 7614fba commit 63b21e9

File tree

7 files changed

+41
-0
lines changed

7 files changed

+41
-0
lines changed

.idea/.gitignore

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/sloglint.iml

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sloglint.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ var slogFuncs = map[string]struct {
129129
"log/slog.InfoContext": {argsPos: 2},
130130
"log/slog.WarnContext": {argsPos: 2},
131131
"log/slog.ErrorContext": {argsPos: 2},
132+
"log/slog.Group": {argsPos: 1},
132133
"(*log/slog.Logger).With": {argsPos: 0, skipContextCheck: true},
133134
"(*log/slog.Logger).Log": {argsPos: 3},
134135
"(*log/slog.Logger).LogAttrs": {argsPos: 3},

testdata/src/kv_only/kv_only.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ func tests() {
88
slog.Info("msg", "foo", 1, "bar", 2)
99
slog.With("foo", 1).Info("msg")
1010
slog.With("foo", 1, "bar", 2).Info("msg")
11+
slog.Group("group", "foo", 1, "baz", 2)
1112

1213
slog.Info("msg", slog.Int("foo", 1)) // want `attributes should not be used`
1314
slog.Info("msg", slog.Int("foo", 1), slog.Int("bar", 2)) // want `attributes should not be used`
1415
slog.Info("msg", "foo", 1, slog.Int("bar", 2)) // want `attributes should not be used`
1516
slog.With(slog.Int("foo", 1)).Info("msg") // want `attributes should not be used`
1617
slog.With(slog.Int("foo", 1), slog.Int("bar", 2)).Info("msg") // want `attributes should not be used`
1718
slog.With("foo", 1, slog.Int("bar", 2)).Info("msg") // want `attributes should not be used`
19+
slog.Group("group", slog.String("foo", "1")) // want `attributes should not be used`
1820

1921
args := []any{"foo", 1, "bar", 2}
2022
slog.Log(nil, slog.LevelInfo, "msg", args...)

testdata/src/no_mixed_args/no_mixed_args.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ func tests() {
1717
slog.With("foo", 1, "bar", 2).Info("msg")
1818
slog.With(slog.Int("foo", 1)).Info("msg")
1919
slog.With(slog.Int("foo", 1), slog.Int("bar", 2)).Info("msg")
20+
slog.Group("group", "foo", 1, "baz", 2)
21+
slog.Group("group", slog.String("foo", "1"))
2022

2123
slog.Log(ctx, slog.LevelInfo, "msg", "foo", 1, slog.Int("bar", 2)) // want `key-value pairs and attributes should not be mixed`
2224
slog.Debug("msg", "foo", 1, slog.Int("bar", 2)) // want `key-value pairs and attributes should not be mixed`
@@ -28,6 +30,7 @@ func tests() {
2830
slog.WarnContext(ctx, "msg", "foo", 1, slog.Int("bar", 2)) // want `key-value pairs and attributes should not be mixed`
2931
slog.ErrorContext(ctx, "msg", "foo", 1, slog.Int("bar", 2)) // want `key-value pairs and attributes should not be mixed`
3032
slog.With("foo", 1, slog.Int("bar", 2)).ErrorContext(ctx, "msg") // want `key-value pairs and attributes should not be mixed`
33+
slog.Group("group", slog.String("foo", "1"), "baz", 2) // want `key-value pairs and attributes should not be mixed`
3134

3235
logger.Log(ctx, slog.LevelInfo, "msg", "foo", 1, slog.Int("bar", 2)) // want `key-value pairs and attributes should not be mixed`
3336
logger.Debug("msg", "foo", 1, slog.Int("bar", 2)) // want `key-value pairs and attributes should not be mixed`

0 commit comments

Comments
 (0)