-
Notifications
You must be signed in to change notification settings - Fork 28
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
add lagerctx package #25
Conversation
Hey xoebus! Thanks for submitting this pull request! I'm here to inform the recipients of the pull request that you and the commit authors have already signed the CLA. |
We have created an issue in Pivotal Tracker to manage this: https://www.pivotaltracker.com/story/show/145647699 The labels on this github issue will be updated when the story is started. |
I switched over a component of our service to use this. I'm pretty happy with how it turned out. The interface looks far cleaner now. |
Thanks, @xoebus ! Looks pretty reasonable to me, but you can't trust me nowadays, so let's have a pair from Diego look over it too. I'm not sure of the community conventions for context-stored types and their null or default values, but would it make sense to export the Thanks, |
I'm following a pattern set forward by the I'm not a fan of consumers of this package needing to reach inside the context to understand what kind of logger they're getting back. They should just be treating it as them being given something which corresponds to the |
I've been thinking of adding a new function to func NewContext(parent context.Context, name string) context.Context {
return lgctx.NewContext(parent, NewTestLogger(name))
} Maybe also allowing the parent context to be |
@xoebus, we looked the PR over and it looks good to us. We agree that there is no need to export To bikeshed slightly, we thinking about whether |
I chose brevity here because this package name will be appearing quite a lot of times throughout a codebase if it is used. There's some prior art here in the standard library e.g. |
Package lagerctx lets Lager Loggers be put inside the standard library Context type.
I've updated the PR with the new package name. Does Lager need to work on Go versions before 1.7? |
per @ematpl it is fine to only support go 1.7 and later (link to the slack conversation) |
Passing both a
Context
andLogger
into a lot of functions was pretty exasperating. I'm looking for feedback on this new package to avoid the bloat.Let me know what you think!