Module: LogStruct::Integrations::RailsLogSubscribers
- Extended by:
- T::Sig
- Defined in:
- lib/log_struct/integrations/rails_log_subscribers.rb
Overview
Rails' own log subscribers, which LogStruct's lines replace
Class Method Summary collapse
-
.detach(subscriber_class, namespace) ⇒ void
Detaches a framework's log subscriber (ActiveStorage::LogSubscriber, :active_storage).
-
.unsubscribe_from_events(subscriber_class) ⇒ void
Unsubscribes a Rails 8.2 log subscriber from Rails.event.
Class Method Details
.detach(subscriber_class, namespace) ⇒ void
This method returns an undefined value.
Detaches a framework's log subscriber (ActiveStorage::LogSubscriber, :active_storage). Up to Rails 8.1 it's an ActiveSupport::LogSubscriber attached to the framework's notifications; from Rails 8.2 it's an ActiveSupport::EventReporter::LogSubscriber, subscribed to Rails.event when its file loads.
14 15 16 17 18 19 20 |
# File 'lib/log_struct/integrations/rails_log_subscribers.rb', line 14 def self.detach(subscriber_class, namespace) if subscriber_class.respond_to?(:detach_from) subscriber_class.detach_from(namespace) else unsubscribe_from_events(subscriber_class) end end |
.unsubscribe_from_events(subscriber_class) ⇒ void
This method returns an undefined value.
Unsubscribes a Rails 8.2 log subscriber from Rails.event. Does nothing for one that isn't subscribed there.
24 25 26 27 28 29 |
# File 'lib/log_struct/integrations/rails_log_subscribers.rb', line 24 def self.unsubscribe_from_events(subscriber_class) return unless ::ActiveSupport.respond_to?(:event_reporter) reporter = ::ActiveSupport.event_reporter reporter.unsubscribe(subscriber_class) if reporter.respond_to?(:unsubscribe) end |