diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e3bc81..7a212b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ - Add `batch_broadcasts` option to automatically batch broadcasts for code wrapped in Rails executor. ([@palkan][]) +- Fix broadcast logging in Rails 7.1. ([@iuri-gg][]) + ## 1.4.1 (2023-09-27) - Fix compatibility with Rails 7.1. ([@palkan][]) diff --git a/lib/anycable/rails/railtie.rb b/lib/anycable/rails/railtie.rb index bb969ef..613c489 100644 --- a/lib/anycable/rails/railtie.rb +++ b/lib/anycable/rails/railtie.rb @@ -31,8 +31,8 @@ class Railtie < ::Rails::Railtie # :nodoc: console.level = ::Rails.logger.level if ::Rails.logger.respond_to?(:level) # Rails 7.1+ - if defined?(ActiveSupport::BroadcastLogger) - AnyCable.logger = ActiveSupport::BroadcastLogger.new(AnyCable.logger, console) + if AnyCable.logger.respond_to?(:broadcast_to) + AnyCable.logger.broadcast_to(console) else AnyCable.logger.extend(ActiveSupport::Logger.broadcast(console)) end