From 0fcfad2030c3558471f6136339a06b87c3d888f2 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Tue, 5 Jul 2016 16:49:40 +0900 Subject: [PATCH] Better way of suppressing render_partial logs --- lib/kaminari/helpers/action_view_extension.rb | 28 ++----------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/lib/kaminari/helpers/action_view_extension.rb b/lib/kaminari/helpers/action_view_extension.rb index 8b41ca7..dae49d9 100644 --- a/lib/kaminari/helpers/action_view_extension.rb +++ b/lib/kaminari/helpers/action_view_extension.rb @@ -140,32 +140,10 @@ module Kaminari undef :to_s # Redefining to_s not to log each render_partial def to_s #:nodoc: - subscriber = ActionView::LogSubscriber.log_subscribers.detect {|ls| ls.is_a? ActionView::LogSubscriber} - - # There is a logging subscriber - # and we don't want it to log render_partial - # It is threadsafe, but might not repress logging - # consistently in a high-load environment - if subscriber - unless defined? subscriber.render_partial_with_logging - class << subscriber - alias_method :render_partial_with_logging, :render_partial - attr_accessor :render_without_logging - # ugly hack to make a renderer where - # we can turn logging on or off - def render_partial(event) - render_partial_with_logging(event) unless render_without_logging - end - end - end - - subscriber.render_without_logging = true - ret = super @window_options.merge :paginator => self - subscriber.render_without_logging = false - - ret + if (logger = ActionView::Base.logger) + logger.silence { super @window_options.merge paginator: self } else - super @window_options.merge :paginator => self + super @window_options.merge paginator: self end end end