Class: Rails::Log::Profiling::ViewLogSubscriber

Inherits:
ActionView::LogSubscriber
  • Object
show all
Defined in:
lib/rails/log/profiling/view_log_subscriber.rb

Instance Method Summary collapse

Instance Method Details

#render_partial(event) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/rails/log/profiling/view_log_subscriber.rb', line 14

def render_partial(event)
  identifier = event.payload[:identifier]
  if Rails::Log::Profiling.rendering_pages[:children].has_key?(identifier)
    Rails::Log::Profiling.rendering_pages[:children][identifier][:partial_count] += 1
  else
    Rails::Log::Profiling.rendering_pages[:children][identifier] = { rendering_time: event.duration.round(1), partial_count: 1 }
  end
end

#render_template(event) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/rails/log/profiling/view_log_subscriber.rb', line 6

def render_template(event)
  Rails::Log::Profiling.rendering_pages[:parent] = [ "#{event.duration.round(1)}", event.payload[:identifier] ]
  children_sort
  view_logger_info
  # グローバル変数のため値をクリアにする
  Rails::Log::Profiling.rendering_pages = { parent: "", children: {} }
end