Class: Searchkick::LogSubscriber
- Inherits:
-
ActiveSupport::LogSubscriber
- Object
- ActiveSupport::LogSubscriber
- Searchkick::LogSubscriber
- Defined in:
- lib/searchkick/logging.rb
Overview
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.reset_runtime ⇒ Object
97 98 99 100 101 |
# File 'lib/searchkick/logging.rb', line 97 def self.reset_runtime rt = runtime self.runtime = 0 rt end |
.runtime ⇒ Object
93 94 95 |
# File 'lib/searchkick/logging.rb', line 93 def self.runtime Thread.current[:searchkick_runtime] ||= 0 end |
.runtime=(value) ⇒ Object
89 90 91 |
# File 'lib/searchkick/logging.rb', line 89 def self.runtime=(value) Thread.current[:searchkick_runtime] = value end |
Instance Method Details
#multi_search(event) ⇒ Object
127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/searchkick/logging.rb', line 127 def multi_search(event) self.class.runtime += event.duration return unless logger.debug? payload = event.payload name = "#{payload[:name]} (#{event.duration.round(1)}ms)" # no easy way to tell which host the client will use host = Searchkick.client.transport.hosts.first debug " #{color(name, YELLOW, true)} curl #{host[:protocol]}://#{host[:host]}:#{host[:port]}/_msearch?pretty -d '#{payload[:body]}'" end |
#request(event) ⇒ Object
117 118 119 120 121 122 123 124 125 |
# File 'lib/searchkick/logging.rb', line 117 def request(event) self.class.runtime += event.duration return unless logger.debug? payload = event.payload name = "#{payload[:name]} (#{event.duration.round(1)}ms)" debug " #{color(name, YELLOW, true)} #{payload.except(:name).to_json}" end |
#search(event) ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/searchkick/logging.rb', line 103 def search(event) self.class.runtime += event.duration return unless logger.debug? payload = event.payload name = "#{payload[:name]} (#{event.duration.round(1)}ms)" type = payload[:query][:type] index = payload[:query][:index].is_a?(Array) ? payload[:query][:index].join(",") : payload[:query][:index] # no easy way to tell which host the client will use host = Searchkick.client.transport.hosts.first debug " #{color(name, YELLOW, true)} curl #{host[:protocol]}://#{host[:host]}:#{host[:port]}/#{CGI.escape(index)}#{type ? "/#{type.map { |t| CGI.escape(t) }.join(',')}" : ''}/_search?pretty -d '#{payload[:query][:body].to_json}'" end |