-
Notifications
You must be signed in to change notification settings - Fork 2
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
Conversation
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 ☂️ |
#### 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. |
There was a problem hiding this comment.
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:
- Can you please make a new versioned release of logr, so I can update my go mod for it?
- Are you good with this section added to my readme?
- 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 withslogcontext
in user code...
Putting the logger into a context and getting a context back could be:ToCtx
,LoggerToCtx
,WithLogger
,CtxWithLogger
,NewCtx
,WithCtx
, or justCtx
Getting it out again could be:Logger
,ToLogger
,CtxToLogger
,LoggerFromCtx
,WithLogger
, orFromCtx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
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.
-
yes
-
the whole lib or just the PR? I am known for being opinionated so be careful what you ask for. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Ok
- Thanks
- 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.
There was a problem hiding this comment.
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 😝
There was a problem hiding this 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 toToCtx
/Logger
, personally - The rest seems pretty approachable!
I agree it is a little weird, though golang seems to support it well enough. Now I am reconsidering, because
Will probably do that. Or
Thx @thockin |
go-logr/logr#234