lib/i2x/detector.rb in i2x-0.0.6 vs lib/i2x/detector.rb in i2x-0.0.7
- old
+ new
@@ -19,13 +19,13 @@
begin
@agent = agent
@payloads = Array.new
@objects = Array.new
@help = I2X::Helper.new
- puts "Loaded new detector: #{agent.identifier}"
+ I2X::Config.log.info(self.class.name) {"Started new #{agent.identifier} detector"}
rescue Exception => e
- p "[i2x] error: #{e}"
+ I2X::Config.log.error(self.class.name) {"#{e}"}
end
end
##
@@ -44,38 +44,38 @@
case seed[:publisher]
when 'csv'
begin
@sr = I2X::CSVSeedReader.new(@agent, seed)
rescue Exception => e
- p "[i2x] error: #{e}"
+ I2X::Config.log.error(self.class.name) {"#{e}"}
end
when 'sql'
begin
@sr = I2X::SQLSeedReader.new(@agent, seed)
rescue Exception => e
- p "[i2x] error: #{e}"
+ I2X::Config.log.error(self.class.name) {"#{e}"}
end
when 'xml'
begin
@sr = I2X::XMLSeedReader.new(@agent, seed)
rescue Exception => e
- p "[i2x] error: #{e}"
+ I2X::Config.log.error(self.class.name) {"#{e}"}
end
when 'json'
begin
@sr = I2X::JSONSeedReader.new(@agent, seed)
rescue Exception => e
- p "[i2x] error: #{e}"
+ I2X::Config.log.error(self.class.name) {"#{e}"}
end
end
begin
@reads = @sr.read
@reads.each do |read|
@objects.push read
end
rescue Exception => e
- p "[i2x] error: #{e}"
+ I2X::Config.log.error(self.class.name) {"#{e}"}
end
end
else
##
@@ -83,29 +83,28 @@
object = @help.deep_copy @agent.payload
object[:identifier] = @agent.identifier
object[:cache] = @agent.cache
object[:seed] = object[:identifier]
object[:selectors] = @agent.selectors
- p "\n\tSelectors: #{object[:selectors]}"
unless self.content.nil? then
object[:content] = self.content
end
@objects.push object
end
rescue Exception => e
@response = {:status => 404, :message => "[i2x][Detector] failed to load doc, #{e}"}
- p "[i2x] error: #{e}"
+ I2X::Config.log.error(self.class.name) {"#{e}"}
end
begin
# increase detected events count
@templates = Array.new
@response = { :payload => @payloads, :templates => @templates, :status => 100}
rescue Exception => e
@response = {:status => 404, :message => "[i2x][Detector] failed to process queries, #{e}"}
- p "[i2x] error: #{e}"
+ I2X::Config.log.error(self.class.name) {"#{e}"}
end
@response
end
\ No newline at end of file