Skip to content

Commit

Permalink
Merge pull request sunspot#237 from chamnap/master
Browse files Browse the repository at this point in the history
Output solr requests in rails console
  • Loading branch information
rywall committed Aug 16, 2012
2 parents f865b1d + 6e2a71d commit 68dec4e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
12 changes: 12 additions & 0 deletions sunspot_rails/lib/sunspot/rails/log_subscriber.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@ def self.reset_runtime
rt, self.runtime = runtime, 0
rt
end

def self.logger=(logger)
@logger = logger
end

def self.logger
@logger
end

def logger
self.class.logger || Rails.logger
end

def request(event)
self.class.runtime += event.duration
Expand Down
5 changes: 5 additions & 0 deletions sunspot_rails/lib/sunspot/rails/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ class Railtie < ::Rails::Railtie
generators do
load "generators/sunspot_rails.rb"
end

# When loading console, make it output to STDERR.
console do
Sunspot::Rails::LogSubscriber.logger = Logger.new(STDERR)
end

end
end
Expand Down

0 comments on commit 68dec4e

Please sign in to comment.