sentry-go icon indicating copy to clipboard operation
sentry-go copied to clipboard

Create an exp/slog.Handler

Open earthboundkid opened this issue 2 years ago • 2 comments

The Go team have released an experimental structured logger. It is very likely to become a part of the standard library in the future. As a Sentry user, I would like any errors that I log with slog.Error to be sent to Sentry.

The simplest way for this to happen that I can think of is for Sentry to release some kind of slog.Handler that intercepts certain log calls and sends some Sentry before writing them to an underlying wrapped slog.Handler for output to stderr, etc.

earthboundkid avatar Jan 11 '23 16:01 earthboundkid

Go 1.21 was released a few days ago and the standard library now contains the structured logger: https://pkg.go.dev/log/slog

philippgille avatar Aug 10 '23 18:08 philippgille

Someone wrote a client adapting Sentry to work with slog: https://github.com/samber/slog-sentry. For now, my plan is to integrate that, but ISTM, it should be merged in here.

earthboundkid avatar Aug 10 '23 18:08 earthboundkid