------art_57660_29473774.1181889257417
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hello,

I'd like to have a logging function which either tells me that the text
files have been created successfully or that provides me an error message
should there have been a fatal error. In doing so I coded the following.
Note, however, that a logfile is created but neither of the comments
mentioned above are shown. Why?


# loads the library modules into the Ruby program
require 'rubygems'
require 'hpricot'
require 'open-uri'
require 'logger'

# create a log file
def do_at_exit(message,exit_code,logger)
  at_exit { logger.fatal(message) if exit_code 1 }
  Process.exit(exit_code)
end

logger  ogger.new('logfile.log')

# logger formats: DEBUG < INFO < WARN < ERROR < FATAL < UNKNOWN
logger.level  ogger::INFO
do_at_exit("Text files successfully created.\n",1,logger) if Process.uid !0

# creates array object and iterates over the collection passing elements one
at a time to the "{ |e| ... }" block
%w(rubygems hpricot open-uri).each { |e| require e }

# check new entries

# Hpricot() method takes an object and loads the contents into a document
object
(1..3).each do |id|
  doc  pricot(open("http://www.securityfocus.com/bid/#{id}"))

# opens a txt-file for each id according to aModeString (w: rite only,
truncates existing file to zero
# length or creates a new file for writing) and returns a new File object
  File.open("#{id}.txt", "w+") do |f|
    f << (doc/'#vulnerability').inner_text
  end

end

------art_57660_29473774.1181889257417--