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
153 154 155 156 157 |
# File 'lib/searchkick/logging.rb', line 153 def self.reset_runtime rt = runtime self.runtime = 0 rt end |
.runtime ⇒ Object
149 150 151 |
# File 'lib/searchkick/logging.rb', line 149 def self.runtime Thread.current[:searchkick_runtime] ||= 0 end |
.runtime=(value) ⇒ Object
145 146 147 |
# File 'lib/searchkick/logging.rb', line 145 def self.runtime=(value) Thread.current[:searchkick_runtime] = value end |
Instance Method Details
#multi_search(event) ⇒ Object
183 184 185 186 187 188 189 190 191 192 193 |
# 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) ⇒ Object
173 174 175 176 177 178 179 180 181 |
# 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) ⇒ Object
159 160 161 162 163 164 165 166 167 168 169 170 171 |
# 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 |