-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
make context.Keys available as LogFormatterParams #1779
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1779 +/- ##
==========================================
+ Coverage 98.62% 98.62% +<.01%
==========================================
Files 41 41
Lines 2112 2113 +1
==========================================
+ Hits 2083 2084 +1
Misses 18 18
Partials 11 11
Continue to review full report at Codecov.
|
@MusicAdam why need it? can you post one usage scenario? thanks! |
closing, thanks! |
@thinkerou Its useful for logging context variables, such as a request-id. It makes the logger more robust. |
Instead of LogFormatterParams containing the context, it is better to add the its parameters or value to LogFormatterParams's field directly. The context in Logger is useful. However, unnecessary methods of context can be used in the Logger. (For example Calling these functions may cause the unexpected bugs. |
This is a good point. I have updated so that context.Keys are passed instead. Since the Keys field is exported, I think it is safe to pass it directly instead of something more complicated like a copy or a separate accessor struct to allow Key retrieval. |
Great! |
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.
LGTM, thanks!
* master: make context.Keys available as LogFormatterParams (gin-gonic#1779) spell check (gin-gonic#1796) chore: use internal/json (gin-gonic#1791)
This makes the context available in LogFormatterParams and therefore allows access to context variables as part of the log output formatting.