|
@ -8,8 +8,8 @@ module Semantic |
|
|
RailsSemanticLogger::ActionController::LogSubscriber.logger.level = :fatal # useful for remanent Rack::Log started |
|
|
RailsSemanticLogger::ActionController::LogSubscriber.logger.level = :fatal # useful for remanent Rack::Log started |
|
|
|
|
|
|
|
|
once_and_reload do |
|
|
once_and_reload do |
|
|
clear_subscribers(/\.action_controller$/) |
|
|
|
|
|
clear_subscribers(/\.action_view$/) |
|
|
|
|
|
|
|
|
NotificationUtil.clear_subscribers(/\.action_controller$/) |
|
|
|
|
|
NotificationUtil.clear_subscribers(/\.action_view$/) |
|
|
|
|
|
|
|
|
append_ansi_formatter |
|
|
append_ansi_formatter |
|
|
reset_subscribers |
|
|
reset_subscribers |
|
@ -52,35 +52,9 @@ module Semantic |
|
|
end |
|
|
end |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
def subscriber_patterns(subscriber) |
|
|
|
|
|
subscriber.patterns.respond_to?(:keys) ? subscriber.patterns.keys : subscriber.patterns |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def unattach(subscriber, pattern) |
|
|
|
|
|
subscriber_patterns(subscriber).each do |sub_pattern| |
|
|
|
|
|
ActiveSupport::Notifications.notifier.listeners_for(sub_pattern).each do |sub| |
|
|
|
|
|
next unless sub.instance_variable_get(:@delegate) == subscriber |
|
|
|
|
|
next unless pattern.match(sub_pattern) |
|
|
|
|
|
|
|
|
|
|
|
puts "FOUND subscriber=#{subscriber} for sub_pattern=#{sub_pattern} with logger #{subscriber.logger.name}" |
|
|
|
|
|
puts subscriber.class.module_parent.const_source_location(subscriber.class.to_s)&.first |
|
|
|
|
|
|
|
|
|
|
|
ActiveSupport::Notifications.unsubscribe(sub) |
|
|
|
|
|
end |
|
|
|
|
|
end |
|
|
|
|
|
ActiveSupport::LogSubscriber.subscribers.delete(subscriber) |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
# pattern could be either a string 'start_processing.action_controller' or a regex /\.action_controller$/ |
|
|
|
|
|
def clear_subscribers(pattern) |
|
|
|
|
|
ActiveSupport::LogSubscriber.subscribers.each { |sub| unattach(sub, pattern) } |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def reset_subscribers |
|
|
def reset_subscribers |
|
|
if defined?(@subscribers) |
|
|
if defined?(@subscribers) |
|
|
@subscribers.each do |sub| |
|
|
|
|
|
ActiveSupport::Notifications.unsubscribe(sub) |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
@subscribers.each { |sub| ActiveSupport::Notifications.unsubscribe(sub) } |
|
|
@subscribers.clear |
|
|
@subscribers.clear |
|
|
else |
|
|
else |
|
|
@subscribers = [] |
|
|
@subscribers = [] |
|
|