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 issue where bootstrap.rb overwrites the level of a BroadcastLogger's broadcasts #49721

Conversation

andrewn617
Copy link
Contributor

Motivation / Background

This Pull Request has been created because in bootstrap.rb we set the Rails.logger.level to config.log_level. But at this point, we may have already set up a BroadcastLogger with multiple broadcasts that have different levels. So, calling level= on the BroadcastLogger will overwrite the level of the individual broadcasts. So instead, let's only set the Rails.logger.level if the logger is not a BroadcastLogger.

Detail

We already have an unless Rails.logger.is_a?(ActiveSupport::BroadcastLogger) block on the next line of the code, so I just move the call to Rails.logger.level = within there.

Additional information

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Changes that are unrelated should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug or add a feature.
  • CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.

…Logger`'s `broadcasts`.

In `bootstrap.rb` we set the `Rails.logger.level` to `config.log_level`. But at this point, we may have already set up a `BroadcastLogger` with multiple broadcasts that have different levels. So, calling `level=` on the `BroadcastLogger` will overwrite the level of the individual broadcasts. So instead, let's only set the `Rails.logger.level` if the logger is not a `BroadcastLogger`.
@rafaelfranca rafaelfranca merged commit 7c58911 into rails:main Oct 20, 2023
4 checks passed
rafaelfranca added a commit that referenced this pull request Oct 20, 2023
…ggers-broadcast-level-in-bootstrap-rb

Fix issue where `bootstrap.rb` overwrites the `level` of a `BroadcastLogger`'s `broadcasts`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants