Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider allowing PC to be passed into Handler #201

Open
thockin opened this issue Aug 4, 2023 · 3 comments
Open

Consider allowing PC to be passed into Handler #201

thockin opened this issue Aug 4, 2023 · 3 comments
Assignees

Comments

@thockin
Copy link
Contributor

thockin commented Aug 4, 2023

This would make bridging from slog a bit cleaner, rather than handlers doing their own unwinding.

@thockin thockin mentioned this issue Aug 4, 2023
4 tasks
@pohly
Copy link
Contributor

pohly commented Aug 4, 2023

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?

@thockin
Copy link
Contributor Author

thockin commented Aug 4, 2023

#204

I did it and then realized exactrly what you said.

@pohly
Copy link
Contributor

pohly commented Aug 8, 2023

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 #205 is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants