From b6d4cc5994dd3d55d832877cfd8c1377419e1733 Mon Sep 17 00:00:00 2001 From: Vladimir Dementyev Date: Tue, 12 Dec 2023 13:34:06 +0300 Subject: [PATCH] fix: create broadcast logger if current is not broadastable --- lib/anycable/rails/railtie.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/anycable/rails/railtie.rb b/lib/anycable/rails/railtie.rb index fd1b164..a53b057 100644 --- a/lib/anycable/rails/railtie.rb +++ b/lib/anycable/rails/railtie.rb @@ -33,8 +33,10 @@ class Railtie < ::Rails::Railtie # :nodoc: # Rails 7.1+ if AnyCable.logger.respond_to?(:broadcast_to) AnyCable.logger.broadcast_to(console) - else + elsif ActiveSupport::Logger.respond_to?(:broadcast) AnyCable.logger.extend(ActiveSupport::Logger.broadcast(console)) + elsif defined?(ActiveSupport::BroadcastLogger) + AnyCable.logger = ActiveSupport::BroadcastLogger.new(AnyCable.logger, console) end end