-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Accept a call scoped context throughout the logging functions
The impetus of this change was to provide a simple mechanism for setting the Person for a particular error message without setting it globally. The globally SetPerson mechanism works for certain use cases, but for many others you want to scope the Person to a smaller surface area. This change introduces a context.Context to most (all?) of the logging methods. For now this only is used to possibly pass a Person to the particular call by using `NewPersonContext`. I decided to use a context rather than accepting a person struct so that we could possibly use this context for cancellation and timeouts in the future, or other scoped values. I added a usage to the example. Most of the tests hit these code paths, but some additional tests might be welcome.
- Loading branch information
Showing
5 changed files
with
144 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.