grafov / kiwi

Fast, structured, with filters and dynamic sinks. No levels. Logger & context keeper for Go language 🥝 It smells like a mushroom.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

I expect log messages to have consistent orders

eric opened this issue · comments

I've noticed that sometimes the order of keys in messages changes from one line to the next and it is very visually confusing when scanning. Is there any thought into making that consistent?

I did it such way for performance. The regular log keys stored in slices and their order is strict but the context keys stored in maps (the context could be added with kiwi.With()). So we have no order in output for the context. It could be annoying I agree. I thought about ways how to handle it properly. The one way is keep the context keys in slices instead of maps. In my common usage I add to the context <10 values so inserts/updates as slices could be comparable in performance with maps. Another way is sort the keys on the output probably in the custom formatter. I think I will add one of these solutions in the future versions of the logger.

Fixed in #2.

Thank you!