Class: ViewSubscriber

Inherits:
CustomLogSpace::BaseSubscriber show all
Defined in:
lib/custom_log_space/subscribers/view_subscriber.rb

Overview

ViewSubscriber logs view rendering events for CustomLogSpace. It tracks events like template rendering, partial rendering, and collection rendering. github.com/rails/rails/blob/7-0-stable/actionview/lib/action_view/log_subscriber.rb

Instance Method Summary collapse

Methods inherited from CustomLogSpace::BaseSubscriber

#process_action, #start_processing

Instance Method Details

#render_collection(event) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/custom_log_space/subscribers/view_subscriber.rb', line 25

def render_collection(event)
  identifier = event.payload[:identifier]
  count = event.payload[:count]
  duration = event.duration.round(2)
  allocations = event.allocations
  message = "Rendered collection #{identifier} (#{count} items) (Duration: #{duration}ms | Allocations: #{allocations})"

  log_message(message)
end

#render_partial(event) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/custom_log_space/subscribers/view_subscriber.rb', line 16

def render_partial(event)
  identifier = event.payload[:identifier]
  duration = event.duration.round(2)
  allocations = event.allocations
  message = "Rendered partial #{identifier} (Duration: #{duration}ms | Allocations: #{allocations})"

  log_message(message)
end

#render_template(event) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/custom_log_space/subscribers/view_subscriber.rb', line 7

def render_template(event)
  identifier = event.payload[:identifier]
  duration = event.duration.round(2)
  allocations = event.allocations
  message = "Rendered #{identifier} (Duration: #{duration}ms | Allocations: #{allocations})"

  log_message(message)
end