chore(log): Tweaking logging again, making everything consistent #101
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is another logging change to make everything consistent. Log
key-value pairs are now done via slog's Attr format based on the notes
at the tail end here: https://go.dev/blog/slog
While this might be a more opinionated change, I see one major benefit.
If the user of the library is wrapping the logging with their own logger
that they are using (zap, logrus or any else) they would have to parse
both the alternating key value pairs and the Attr structs. By only using
the Attr structs the user would only need to handle that one object type
now in their own logging layer; hopefully making integration easier for
them to have consistent logs.
I'm opening this specifically because I'm using logrus for my application and I found that it was unnecessarily
complicated to try to convert both the
Attr
and the alternating key-value pairs to the logrus fields nicely?Ultimately I'm pushing the problem upstream to this library lol, but hopefully in such a way that it would make it
easier for anyone to also implement their own logging consistently using this library.
Please let me know what your thoughts are, this is a somewhat opinionated PR in terms of logging changes. While the
output will be identical for the default logger the code has been changed throughout.