-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Added WithError(err) #179
Added WithError(err) #179
Conversation
This is not unreasonable. I'll think a bit about this. |
👍 |
WDYT about implementing
|
PR is missing functionality in |
@yawn isn't that what you've already done? re adding to I've also decided that this is going in. It should be added to |
I meant
This way we could return errors logged to the context by returning the call to the logging method. I can prepare an example if you want. |
Yeah, I think that's valid. I've wanted to do that before. Logging is often awkward in Go because it can be unclear when to log and when to return an error, and sometimes you even want to do both—because the context you have is not present. But fewer log lines with more information is often better than a lot of log lines with little information, and makes the code harder to read. It should be a separate API, but I'm open to the idea. |
If you could add this to |
I'll do the additions on the train. Regarding the API:
|
Done, with the proposed API (756db3c) as separate commit. |
Do you need anything more from me here @sirupsen? |
LGTM |
This just broke the build of https://github.com/docker/distribution/tree/master/context
|
@gelraen thanks for letting me know, it seems this interface should be updated: https://github.com/docker/distribution/blob/master/context/logger.go#L9-L40 The project uses vendored dependencies so it should not be affected by the change. I'll send them a PR anyways. |
A recent change in logrus broke the expectations of the `context.Logger` interface. We can enforce the expectation by wrapping the `*logrus.Entry` in a type that matches this interface. Logrus change: sirupsen/logrus#179 Signed-off-by: Antoine Grondin <[email protected]>
@aybabtme please also note that this breaks promise of being drop-in replacement for |
It doesn't break the promise for the I can't say what the intent was with regard to compatibility, I'll let @sirupsen decide if he sees it as applying to |
I'd vote for a partial revert of 756db3c then ("changing the return value"). This is not strictly necessary (except for the cast-to-error usecase) for this PR but is probably useful in any case. It's just seems to break compatibility ... |
Fortunately this was never released as a version. Thanks for your quick revert @aybabtme. |
Added WithError(err)
Added WithError(err)
This is very small feature request for a function of
logrus
I use all the time: adding an error message to the context.