News for hackers. Stuff that matters.
Re:Slogtest by ming13 on Thursday August 17, 2023 @01:29AM (#37157612)
A thing I appreciate about Go — there are such testing-scoped packages built-in. As I’ve experienced, this approach encourages a good testing culture in teams.
Re:Slogtest by zknill on Thursday August 17, 2023 @01:52AM (#37157753)
The new structured logging library is a great addition, its nice to have structured logging in the standard lib.

It's easy to get started with log/slog and one of the built in handlers, but as soon as you want to change something the library design pushes you towards implementing an entire handler.

For example, if I was the built in JSON format, but with a different formatting of the Time field, that's not easy to do. It's not obvious how to change the built in handler.

I wrote slogmw[1] to solve this problem. It's a set of middleware and examples that make it easy to make small changes to the built in handlers without having to write a whole new handler from scratch.

[1] https://github.com/zknill/slogmw