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

Logr Interoperability #1

Merged
merged 6 commits into from Dec 21, 2023
Merged

Logr Interoperability #1

merged 6 commits into from Dec 21, 2023

Conversation

veqryn
Copy link
Owner

@veqryn veqryn commented Nov 26, 2023

@codecov-commenter
Copy link

Welcome to Codecov 🎉

Once merged to your default branch, Codecov will compare your coverage reports and display the results in this comment.

Thanks for integrating Codecov - We've got you covered ☂️

Comment on lines +41 to +49
#### Compatibility with both Slog and Logr
slog-context is compatible with both standard library [slog](https://pkg.go.dev/log/slog)
and with [logr](https://github.com/go-logr/logr), which is an alternative
logging api/interface/frontend.

If only slog is used, only `*slog.Logger`'s will be stored in the context.
If both slog and logr are used, `*slog.Logger` will be automatically converted
to a `logr.Logger` as needed, and vice versa. This allows full interoperability
down the stack and with any libraries that use either slog-context or logr.
Copy link
Owner Author

Choose a reason for hiding this comment

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

@pohly @thockin hey guys, i have a few requests:

  1. Can you please make a new versioned release of logr, so I can update my go mod for it?
  2. Are you good with this section added to my readme?
  3. If you have time, I wouldn't mind a review of my library. In particular I am debating the names I've chosen, like for putting the logger in (ToCtx) and getting it out again (Logger).
    They would all be prefixed with slogcontext in user code...
    Putting the logger into a context and getting a context back could be: ToCtx, LoggerToCtx, WithLogger, CtxWithLogger, NewCtx, WithCtx, or just Ctx
    Getting it out again could be: Logger, ToLogger, CtxToLogger, LoggerFromCtx, WithLogger, or FromCtx

Copy link

@thockin thockin Dec 2, 2023

Choose a reason for hiding this comment

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

  1. let's not rush (or we can do an rc1). I already found at least 1 (minor, because @pohly is awesome) bug, and I have proposed funcr support for slog.

  2. yes

  3. the whole lib or just the PR? I am known for being opinionated so be careful what you ask for. :)

Copy link
Owner Author

Choose a reason for hiding this comment

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

  1. Ok
  2. Thanks
  3. As much as you have time for. I may not take all advice, but I will consider everything. My priority would be on settling the external api (naming and function signatures) for my whole lib, followed by everything else. The library is still new and still version 0.x.x, so there is room to change things.

Copy link

Choose a reason for hiding this comment

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

README looks good to me.

I'll leave 3 to @thockin - he's better at criticizing naming than I am 😝

Copy link

@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.

Here's some notes, take 'em or not :)

  • package name vs repo name - weird when they are not the same.
  • slogctx would be a great pkg name :)
  • I prefer the NewContext / FromContext pattern to ToCtx / Logger, personally
  • The rest seems pretty approachable!

@veqryn
Copy link
Owner Author

veqryn commented Dec 5, 2023

Here's some notes, take 'em or not :)

  • package name vs repo name - weird when they are not the same.
  • slogctx would be a great pkg name :)

I agree it is a little weird, though golang seems to support it well enough.
I actually based the name off all the already existing slog libraries under the slog blog/wiki: https://github.com/golang/go/wiki/Resources-for-slog
All of them seemed to be named slog-<something> and their root packages named slog<something>.

Now I am reconsidering, because slogctx is a good and short name...

  • I prefer the NewContext / FromContext pattern to ToCtx / Logger, personally

Will probably do that. Or NewCtx and FromCtx

  • The rest seems pretty approachable!

Thx @thockin

@veqryn veqryn merged commit a396e33 into main Dec 21, 2023
9 checks passed
@veqryn veqryn deleted the logr branch December 21, 2023 08:43
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.

None yet

4 participants