class Searchkick::LogSubscriber
github.com/rails/rails/blob/master/activerecord/lib/active_record/log_subscriber.rb
Public Class Methods
reset_runtime()
click to toggle source
# File lib/searchkick/logging.rb, line 153 def self.reset_runtime rt = runtime self.runtime = 0 rt end
runtime()
click to toggle source
# File lib/searchkick/logging.rb, line 149 def self.runtime Thread.current[:searchkick_runtime] ||= 0 end
runtime=(value)
click to toggle source
# File lib/searchkick/logging.rb, line 145 def self.runtime=(value) Thread.current[:searchkick_runtime] = value end
Public Instance Methods
multi_search(event)
click to toggle source
# File lib/searchkick/logging.rb, line 183 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 -H 'Content-Type: application/json' -d '#{payload[:body]}'" end
request(event)
click to toggle source
# File lib/searchkick/logging.rb, line 173 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)
click to toggle source
# File lib/searchkick/logging.rb, line 159 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 -H 'Content-Type: application/json' -d '#{payload[:query][:body].to_json}'" end