go-simpler / sloglint

🪵 Ensure consistent code style when using log/slog
https://go-simpler.org/sloglint
Mozilla Public License 2.0
75 stars 5 forks source link

Allow slog.Group() when setting no-mixed-args: true or kv-only: true #50

Open cfiderer opened 2 weeks ago

cfiderer commented 2 weeks ago

The slog.Group() function is the only means to put some grouped data elements between other elements into the log.

A call like

logger.Info("message", "key1", value1, slog.Group("group", "key2", value2, "key3", value3), "key4", value4)

should be allowed, and the arguments to slog.Group() should be checked for key-value pairs, too.

tmzane commented 2 weeks ago

I completely forgot that slog.Group() existed. I agree, it should not be reported.