Method: Chewy::LogSubscriber#render_action

Defined in:
lib/chewy/log_subscriber.rb

#render_action(action, event) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/chewy/log_subscriber.rb', line 19

def render_action(action, event)
  payload = event.payload
  description = yield(payload)

  return if description.blank?

  subject = payload[:type].presence || payload[:index]
  action = "#{subject} #{action} (#{event.duration.round(1)}ms)"
  action = if ActiveSupport.version >= Gem::Version.new('7.1')
    color(action, GREEN, bold: true)
  else
    color(action, GREEN, true)
  end

  debug("  #{action} #{description}")
end