acaloiaro / neoq

Queue-agnostic background job library for Go, with a pleasant API and powerful features.
MIT License
270 stars 4 forks source link

chore(log): Tweaking logging again, making everything consistent #101

Closed elliotcourant closed 11 months ago

elliotcourant commented 11 months ago

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.

elliotcourant commented 11 months ago

I've broken tests, moving this to a draft while I sort that out