Skip to content

Commit

Permalink
Use ActiveSupport.on_load to defer autoloaded Action Cable constants
Browse files Browse the repository at this point in the history
Co-authored-by: Rob Brackett <rob@robbrackett.com>
  • Loading branch information
bensheldon and Mr0grog committed Jul 26, 2024
1 parent 711231e commit 5791cc4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
5 changes: 4 additions & 1 deletion lib/lograge/rails_ext/action_cable/channel/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@ def notification_payload(method_name)
end
end

ActionCable::Channel::Base.prepend(Lograge::ActionCable::ChannelInstrumentation)

ActiveSupport.on_load(:action_cable_channel) do
ActionCable::Channel::Base.prepend(Lograge::ActionCable::ChannelInstrumentation)
end
4 changes: 3 additions & 1 deletion lib/lograge/rails_ext/action_cable/connection/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ def notification_payload(method_name)
end
end

ActionCable::Connection::Base.prepend(Lograge::ActionCable::ConnectionInstrumentation)
ActiveSupport.on_load(:action_cable_connection) do
ActionCable::Connection::Base.prepend(Lograge::ActionCable::ConnectionInstrumentation)
end
12 changes: 7 additions & 5 deletions lib/lograge/rails_ext/action_cable/server/base.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# frozen_string_literal: true

module ActionCable
module Server
class Base
mattr_accessor :logger
self.logger = Lograge::SilentLogger.new(config.logger)
ActiveSupport.on_load(:action_cable) do
module ActionCable
module Server
class Base
mattr_accessor :logger
self.logger = Lograge::SilentLogger.new(config.logger)
end
end
end
end

0 comments on commit 5791cc4

Please sign in to comment.