Sha256: f3e977bcbcdfeb90f803ed4fa33928cf3d90e6b675c2ee3fbc94e9fc0977c0c9
Contents?: true
Size: 1.31 KB
Versions: 16
Compression:
Stored size: 1.31 KB
Contents
module Sunspot module Rails class LogSubscriber < ActiveSupport::LogSubscriber def self.runtime=(value) Thread.current["sorl_runtime"] = value end def self.runtime Thread.current["sorl_runtime"] ||= 0 end def self.reset_runtime rt, self.runtime = runtime, 0 rt end def self.logger=(logger) @logger = logger end def self.logger @logger if defined?(@logger) end def logger self.class.logger || ::Rails.logger end def request(event) self.class.runtime += event.duration return unless logger.debug? name = '%s (%.1fms)' % ["SOLR Request", event.duration] # produces: path=select parameters={fq: ["type:Tag"], q: "rossi", fl: "* score", qf: "tag_name_text", defType: "edismax", start: 0, rows: 20} path = color(event.payload[:path], BOLD, true) parameters = event.payload[:parameters].map { |k, v| v = "\"#{v}\"" if v.is_a? String v = v.to_s.gsub(/\\/,'') # unescape "#{k}: #{color(v, BOLD, true)}" }.join(', ') request = "path=#{path} parameters={#{parameters}}" debug " #{color(name, GREEN, true)} [ #{request} ]" end end end end Sunspot::Rails::LogSubscriber.attach_to :rsolr
Version data entries
16 entries across 16 versions & 2 rubygems