Sha256: cb1f18044a1ebe01b08a24a2c778f32b1dfbd40acb797f00f4796f05bd6484bf
Contents?: true
Size: 1.3 KB
Versions: 7
Compression:
Stored size: 1.3 KB
Contents
module Logtail module Integrations module Rails # @private module ActiveSupportLogSubscriber extend self def find(component, type) ::ActiveSupport::LogSubscriber.log_subscribers.find do |subscriber| subscriber.class == type end end def subscribed?(component, type) !find(component, type).nil? end # I don't know why this has to be so complicated, but it is. This code was taken from # lograge :/ def unsubscribe!(component, type) if defined?(type.detach_from) type.detach_from(component) return end subscriber = find(component, type) if !subscriber raise "We could not find a log subscriber for #{component.inspect} of type #{type.inspect}" end events = subscriber.public_methods(false).reject { |method| method.to_s == 'call' } events.each do |event| ::ActiveSupport::Notifications.notifier.listeners_for("#{event}.#{component}").each do |listener| if listener.instance_variable_get('@delegate') == subscriber ::ActiveSupport::Notifications.unsubscribe listener end end end end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems