lib/spidey/strategies/mongo.rb in spidey-mongo-0.0.5 vs lib/spidey/strategies/mongo.rb in spidey-mongo-0.1.0

- old
+ new

@@ -14,21 +14,21 @@ @until = Time.now + options[:crawl_for] if options[:crawl_for] super options end def handle(url, handler, default_data = {}) - $stderr.puts "Queueing #{url.inspect.truncate(500)}" if verbose + Spidey.logger.info "Queueing #{url.inspect[0..200]}..." url_collection.update( {'spider' => self.class.name, 'url' => url}, {'$set' => {'handler' => handler, 'default_data' => default_data}}, upsert: true ) end def record(data) doc = data.merge('spider' => self.class.name) - $stderr.puts "Recording #{doc.inspect.truncate(500)}" if verbose + Spidey.logger.info "Recording #{doc.inspect[0..500]}..." if respond_to?(:result_key) && key = result_key(doc) result_collection.update({'key' => key}, {'$set' => doc}, upsert: true) else result_collection.insert doc end @@ -44,10 +44,10 @@ def add_error(attrs) error = attrs.delete(:error) doc = attrs.merge(created_at: Time.now, error: error.class.name, message: error.message, spider: self.class.name) error_collection.insert doc - $stderr.puts "Error on #{attrs[:url]}. #{error.class}: #{error.message}" if verbose + Spidey.logger.error "Error on #{attrs[:url]}. #{error.class}: #{error.message}" end private def get_next_url