logr
logr copied to clipboard
Consider allowing PC to be passed into Handler
This would make bridging from slog a bit cleaner, rather than handlers doing their own unwinding.
I had considered this. It seems doable.
I did not pursue it further because it won't work with current LogSink implementations. If we expect implementations to be modified, wouldn't it be better to support slog directly?
https://github.com/go-logr/logr/pull/204
I did it and then realized exactrly what you said.
The alternative is an interface that is specific to slog:
// SlogSink is an interface that a LogSink can implement to support logging
// through the slog.Logger or slog.Handler APIs better. It then should
// also support special slog values like slog.Group.
type SlogSink interface {
logr.LogSink
Handle(ctx context.Context, record slog.Record) error
WithAttrs(attrs []slog.Attr) SlogSink
WithGroup(name string) SlogSink
}
I'll prepare a PR with that once https://github.com/go-logr/logr/pull/205 is merged.