Class: Chewy::LogSubscriber
- Inherits:
-
ActiveSupport::LogSubscriber
- Object
- ActiveSupport::LogSubscriber
- Chewy::LogSubscriber
- Defined in:
- lib/chewy/log_subscriber.rb
Instance Method Summary collapse
- #delete_query(event) ⇒ Object
- #import_objects(event) ⇒ Object
- #logger ⇒ Object
- #render_action(action, event) ⇒ Object
- #search_query(event) ⇒ Object
Instance Method Details
#delete_query(event) ⇒ Object
15 16 17 |
# File 'lib/chewy/log_subscriber.rb', line 15 def delete_query(event) render_action('Delete by Query', event) { |payload| payload[:request] } end |
#import_objects(event) ⇒ Object
7 8 9 |
# File 'lib/chewy/log_subscriber.rb', line 7 def import_objects(event) render_action('Import', event) { |payload| payload[:import] } end |
#logger ⇒ Object
3 4 5 |
# File 'lib/chewy/log_subscriber.rb', line 3 def logger Chewy.logger end |
#render_action(action, event) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# 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 = color(action, GREEN, true) debug(" #{action} #{description}") end |
#search_query(event) ⇒ Object
11 12 13 |
# File 'lib/chewy/log_subscriber.rb', line 11 def search_query(event) render_action('Search', event) { |payload| payload[:request] } end |