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

Update log.entry() To Not Use Global Logger #1524

Merged
merged 2 commits into from
Jun 29, 2022
Merged

Update log.entry() To Not Use Global Logger #1524

merged 2 commits into from
Jun 29, 2022

Conversation

ihcsim
Copy link
Contributor

@ihcsim ihcsim commented Jun 29, 2022

Change Overview

This PR updates the log.entry() function to not bind new logrus.Entry instances to the global logger, to ensure that changes made to the entries' loggers do not escape to the global level. It ensures that all new entries are bound to clones of the global logger.

Without this change, if an entry is changed to output its log lines to a custom io.Writer, the global logger will also be changed to write logs the custom io.Writer. Also, when concurrent callers attempt to change the output target of their respective log entries, the global logger will end up with racey outputs.

Fixes #1532.

Signed-off-by: Ivan Sim ivan.sim@kasten.io

Pull request type

Please check the type of change your PR introduces:

  • 🚧 Work in Progress
  • 🌈 Refactoring (no functional changes, no api changes)
  • 🐹 Trivial/Minor
  • 🐛 Bugfix
  • 🌻 Feature
  • 🗺️ Documentation
  • 🤖 Test

Issues

Test Plan

  • 💪 Manual
  • ⚡ Unit test
  • 💚 E2E

Multiple log entries sharing a global logger can cause changes to the
entries' loggers to escape to the global level. For example, if an entry
is changed to output its log lines to a custom io.Writer, the global
logger will also be changed to write logs the custom io.Writer.

Also, when concurrent callers attempt to change the output target of
their respective log entries, the global logger will end up with racey
outputs.

This change clones the global logger inside the log.entry() function and
binds the clone logger to the entry instance.

Signed-off-by: Ivan Sim <ivan.sim@kasten.io>
@ihcsim ihcsim requested a review from pavannd1 June 29, 2022 21:42
@github-actions
Copy link
Contributor

Thanks for submitting this pull request 🎉. The team will review it soon and get back to you.

If you haven't already, please take a moment to review our project contributing guideline and Code of Conduct document.

@infraq infraq added this to In Progress in Kanister Jun 29, 2022
@ihcsim ihcsim requested a review from e-sumin June 29, 2022 21:42
Kanister automation moved this from In Progress to Reviewer approved Jun 29, 2022
Copy link
Contributor

@pavannd1 pavannd1 left a comment

Choose a reason for hiding this comment

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

LGTM

@ihcsim ihcsim added the kueue label Jun 29, 2022
@mergify mergify bot merged commit a5627cd into master Jun 29, 2022
Kanister automation moved this from Reviewer approved to Done Jun 29, 2022
@mergify mergify bot deleted the logs-buffer branch June 29, 2022 22:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants