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 mixing of key-value pairs and attributes #23

Closed n9v9 closed 6 months ago

n9v9 commented 7 months ago

Hi, would you be open to add a flag to allow the mixing of key-value pairs and attributes? If I see it correctly, then it is currently hard-coded to be forbidden.

It would be useful for cases that use helper functions like func Err(err error) slog.Attr for commonly used fields, while still adding other key value pairs to a log message.

It could be implement in a backwards compatible way, and I could provide a PR.

tmzane commented 7 months ago

@n9v9 Hi, sorry for the late reply.

I agree, it would indeed be useful to perform other checks while being able to mix arguments in some cases. We already have tests for it, so implementing the -no-mixed-args (maybe a better name?) option and setting it to true by default should be enough.

I'd be happy to accept your PR!