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

docs: interoperability with slog #222

Merged
merged 1 commit into from Oct 23, 2023

Conversation

pohly
Copy link
Contributor

@pohly pohly commented Sep 13, 2023

This assumes that context helper
functions (#213) for slog will not get merged. If that is the consensus, then this documentation should be the last missing piece for slog support in logr.

Fixes: #212

@@ -21,7 +21,8 @@ limitations under the License.
// API and of a logr.LogSink through the slog.Handler and thus slog.Logger
// APIs.
//
// Both approaches are currently experimental and need further work.
// See the README in the top-level [./logr] package for a discussion of
// interoperability.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My hope is that pkg.go.dev will render this as a link. I've not tried to verify that beforehand because it's not that simple anymore, with godoc being deprecated...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't get pksite to work - it seems to look at github for something, and refuses to include the ./slogr directory

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tried at all. I guess we'll have to hope for the best and check after a release.

@pohly
Copy link
Contributor Author

pohly commented Oct 23, 2023

@mengjiao-liu: Have you had a chance to catch up on the log/slog interoperability discussion? This PR and the commits in master since the last release are good opportunity to catch up.

Your review comments on this PR would also be useful.

@thockin
Copy link
Contributor

thockin commented Oct 23, 2023

I didn't mean to quietly kill #213 - I have just had zero free moments to think about it. Is this PR a case of "oh well, let's just document it" ?

Copy link
Contributor

@thockin thockin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm OK to merge this and followup with context PR(s) after kubecon

/lgtm

README.md Outdated
Not supporting slog has several drawbacks:
- Recording source code locations works correctly if the handler gets called
through `slog.Logger`, but may be wrong in other cases. That's because a
`slog.Sink` does its own stack unwinding instead of using the program counter
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

slog.Sink is not a type I know? Do yhou mean logr.Sink ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, that should have been logr.Sink - fixed.

@@ -21,7 +21,8 @@ limitations under the License.
// API and of a logr.LogSink through the slog.Handler and thus slog.Logger
// APIs.
//
// Both approaches are currently experimental and need further work.
// See the README in the top-level [./logr] package for a discussion of
// interoperability.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't get pksite to work - it seems to look at github for something, and refuses to include the ./slogr directory

@pohly
Copy link
Contributor Author

pohly commented Oct 23, 2023

Is this PR a case of "oh well, let's just document it" ?

It documents the current status, so we can merge it and then decide whether we want further code and docs changes in a future PR. I think it is safe to tag after merging this PR, because I am relatively confident that we can keep the current slogr package API even if we move around all code inside it (which is a possibility, for example if we want logr.FromContext to support slog).

This assumes that context helper
functions (go-logr#213) for slog will not get
merged. If that is the consensus, then this documentation should be the last
missing piece for slog support in logr.
@thockin thockin merged commit 8adefbe into go-logr:master Oct 23, 2023
14 checks passed
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

Successfully merging this pull request may close these issues.

TODO: Write a nice doc on logr <-> slog
2 participants