Skip to content

Commit

Permalink
Use Blacklight.logger instead of hard-coding Rails.logger
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Mar 13, 2015
1 parent 527b950 commit 7846593
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
8 changes: 7 additions & 1 deletion lib/blacklight.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,13 @@ def self.solr_yml
end

def self.logger
::Rails.logger
@logger ||= begin
::Rails.logger if defined? Rails and Rails.respond_to? :logger
end
end

def self.logger= logger
@logger = logger
end

#############
Expand Down
2 changes: 1 addition & 1 deletion lib/blacklight/abstract_repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def connection_config
end

def logger
@logger ||= Rails.logger if defined? Rails
@logger ||= Blacklight.logger
end
end
end
2 changes: 1 addition & 1 deletion lib/blacklight/catalog/search_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def setup_next_and_previous_documents
@next_document = documents.last
end
rescue Blacklight::Exceptions::InvalidRequest => e
Rails.logger.warn "Unable to setup next and previous documents: #{e}"
logger.warn "Unable to setup next and previous documents: #{e}"
end

end
4 changes: 2 additions & 2 deletions lib/blacklight/solr_repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ def send_and_receive(path, solr_params = {})

solr_response = blacklight_config.response_model.new(res, solr_params, document_model: blacklight_config.document_model)

Rails.logger.debug("Solr query: #{solr_params.inspect}")
Rails.logger.debug("Solr response: #{solr_response.inspect}") if defined?(::BLACKLIGHT_VERBOSE_LOGGING) and ::BLACKLIGHT_VERBOSE_LOGGING
Blacklight.logger.debug("Solr query: #{solr_params.inspect}")
Blacklight.logger.debug("Solr response: #{solr_response.inspect}") if defined?(::BLACKLIGHT_VERBOSE_LOGGING) and ::BLACKLIGHT_VERBOSE_LOGGING
solr_response
end
rescue Errno::ECONNREFUSED => e
Expand Down

0 comments on commit 7846593

Please sign in to comment.