Skip to content

Commit

Permalink
Fix issue where bootstrap.rb overwrites the level of a `Broadcast…
Browse files Browse the repository at this point in the history
…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`.
  • Loading branch information
andrewn617 committed Oct 20, 2023
1 parent 10d880d commit f212fb8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions activesupport/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
* Fix issue where `bootstrap.rb` overwrites the `level` of a `BroadcastLogger`'s `broadcasts`.

*Andrew Novoselac*

* Fix compatibility with the `semantic_logger` gem.

The `semantic_logger` gem doesn't behave exactly like stdlib logger in that
Expand Down
2 changes: 1 addition & 1 deletion railties/lib/rails/application/bootstrap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ module Bootstrap
)
logger
end
Rails.logger.level = ActiveSupport::Logger.const_get(config.log_level.to_s.upcase)

unless Rails.logger.is_a?(ActiveSupport::BroadcastLogger)
Rails.logger.level = ActiveSupport::Logger.const_get(config.log_level.to_s.upcase)
broadcast_logger = ActiveSupport::BroadcastLogger.new(Rails.logger)
broadcast_logger.formatter = Rails.logger.formatter
Rails.logger = broadcast_logger
Expand Down

0 comments on commit f212fb8

Please sign in to comment.