Module: EnjuSearchLog::EnjuUser::InstanceMethods
- Defined in:
- lib/enju_search_log/user.rb
Instance Method Summary collapse
- #save_history(query, offset = 0, total = 0, format = nil) ⇒ Object
- #write_search_log(query, total, username, format) ⇒ Object
Instance Method Details
#save_history(query, offset = 0, total = 0, format = nil) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/enju_search_log/user.rb', line 15 def save_history(query, offset = 0, total = 0, format = nil) return nil unless self.save_search_history if LibraryGroup.site_config.settings[:write_search_log_to_file] write_search_log(query, total, username, format) else history = SearchHistory.new(query: query, start_record: offset + 1, maximum_records: nil, number_of_records: total) history.user = self history.save(validate: false) end end |
#write_search_log(query, total, username, format) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/enju_search_log/user.rb', line 26 def write_search_log(query, total, username, format) if Rails::VERSION::MAJOR >= 4 logger = ActiveSupport::Logger.new(File.join(Rails.root, 'log', 'search.log')) else logger = ActiveSupport::BufferedLogger.new(File.join(Rails.root, 'log', 'search.log')) end logger.info "#{Time.zone.now}\t#{query}\t#{total}\t#{username}\t#{format}" end |