Skip to content
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

fix(leak): Avoid mutating logger #97

Conversation

pablomatiasgomez
Copy link
Contributor

@pablomatiasgomez pablomatiasgomez commented Nov 21, 2024

Same as what happened in #69, the same bug was introduced later, in #76

The only reason this was not caught by the test TestCustomLoggerIssue68 is because that feature is using l instead of rl so it's not even working correctly for custom loggers.

cc @appleboy

@pablomatiasgomez pablomatiasgomez changed the title Avoid mutating logger fix(leak): Avoid mutating logger Nov 21, 2024
r.Use(SetLogger(
WithLogger(func(*gin.Context, zerolog.Logger) zerolog.Logger { return l }),
WithLogger(func(_ *gin.Context, l zerolog.Logger) zerolog.Logger { return l.Output(buffer).With().Logger() }),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason why this was not caught by this test is because the modifications to the logger basically add method, path, ip, and user_agent which are ALSO added to the event, but without json it seems to dedupe these keys.

@codecov-commenter
Copy link

codecov-commenter commented Nov 22, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.40%. Comparing base (d96c742) to head (667f961).
Report is 29 commits behind head on master.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #97      +/-   ##
==========================================
+ Coverage   94.24%   94.40%   +0.16%     
==========================================
  Files           2        2              
  Lines         139      143       +4     
==========================================
+ Hits          131      135       +4     
  Misses          5        5              
  Partials        3        3              
Flag Coverage Δ
go- ?
go-1.18 ?
go-1.19 ?
go-1.20 ?
go-1.21 94.40% <100.00%> (+0.16%) ⬆️
go-1.22 94.40% <100.00%> (+0.16%) ⬆️
go-1.23 94.40% <100.00%> (?)
macos-latest ?
ubuntu-latest 94.40% <100.00%> (+0.16%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

@appleboy appleboy merged commit 2406f68 into gin-contrib:master Nov 22, 2024
6 checks passed
@appleboy
Copy link
Member

@pablomatiasgomez Thanks

@pablomatiasgomez pablomatiasgomez deleted the pablomatiasgomez/avoid-mutating-logger branch November 22, 2024 16:31
@pablomatiasgomez
Copy link
Contributor Author

@appleboy Any ideas when this would be released? Thanks!!

@appleboy
Copy link
Member

@pablomatiasgomez https://github.com/gin-contrib/logger/releases/tag/v1.2.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants