▲ | arcaen 2 days ago | |
The thing that gets me about slog is that the output key for the slog JSON handler is msg, but that's not compatible with Googles own GCP Stackdriver logging. Since that key is a constant I now need to use an attribute replacer to change it from msg to message (or whatever it is stackdriver wants). Good work Google. | ||
▲ | ImJasonH 2 days ago | parent [-] | |
We had the same annoyance, and wrote https://pkg.go.dev/github.com/chainguard-dev/clog/gcp to bridge the gap. It's a slog handler that formats everything the way GCP wants, including with trace contexts, etc. We've had this in production for months, and it's been pretty great. You can add this at your main.go
(the rest of the library is about attaching a logger to a context.Context, but you don't need to use that to use the GCP logger) |