module DetailParser
require 'active_support/tagged_logging'
Constants
- VERSION
Attributes
application[RW]
filter[RW]
logger[RW]
Public Instance Methods
attach_to_action_controller()
click to toggle source
# File lib/detail_parser.rb, line 71 def attach_to_action_controller DetailParser::LogSubscriber.attach_to :action_controller end
before_format(data, payload)
click to toggle source
# File lib/detail_parser.rb, line 34 def before_format(data, payload) result = nil result = @@before_format.call(data, payload) if @@before_format result || data end
detail_config()
click to toggle source
# File lib/detail_parser.rb, line 75 def detail_config application.config.detail_parser end
keep_original_log()
click to toggle source
# File lib/detail_parser.rb, line 45 def keep_original_log return if detail_config.keep_original_log remove_existing_log_subscriptions end
remove_existing_log_subscriptions()
click to toggle source
# File lib/detail_parser.rb, line 50 def remove_existing_log_subscriptions ActiveSupport::LogSubscriber.log_subscribers.each do |subscriber| case subscriber when ActionController::LogSubscriber unsubscribe(:action_controller, subscriber) end end end
set_formatter()
click to toggle source
# File lib/detail_parser.rb, line 41 def set_formatter DetailParser.formatter = detail_config.formatter || DetailParser::Formatters::Json.new end
setup(app)
click to toggle source
Your code goes hereā¦
# File lib/detail_parser.rb, line 20 def setup(app) self.application = app keep_original_log attach_to_action_controller set_formatter end
unsubscribe(component, subscriber)
click to toggle source
# File lib/detail_parser.rb, line 60 def unsubscribe(component, subscriber) 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