lib/halog/log_parser.rb
# advance the IO forward if it looks like this logfile has already been parsed.
# advancing the IO only works on actual files.  IO that comes from STDIN 
advance the IO forward if it looks like this logfile has already been parsed.
advancing the IO only works on actual files.  IO that comes from STDIN
advance the IO forward if it looks like this logfile has already been parsed . advancing the IO only works on actual files . IO that comes from STDIN
def advance_io(io,options)
      return io if options.size == 0
      %w[ byte_count starting_offset first_entry_time last_entry_time import_ended_on].each do |c| 
        raise "Missing option '#{c}' from LogParser options." if not options.keys.include?(c)
      end
      seek_to = options['starting_offset'] + options['byte_count']
      if io.stat.size < seek_to then
        $stderr.puts "Looks like log file has been rotated, starting from the beginning."
        return io if io.stat.size < seek_to
      end
      $stderr.puts "Jumping to offset #{seek_to} in file of size #{io.stat.size}."
      io.seek(seek_to,IO::SEEK_SET)
      return io
    end
def advance_io ( io , options ) return io if options . size == 0 %w[ byte_count starting_offset first_entry_time last_entry_time import_ended_on ] . each do | c | raise "Missing option '#{c}' from LogParser options." if not options . keys . include? ( c ) end seek_to = options [ 'starting_offset' ] + options [ 'byte_count' ] if io . stat . size < seek_to then $stderr . puts "Looks like log file has been rotated, starting from the beginning." return io if io . stat . size < seek_to end $stderr . puts "Jumping to offset #{seek_to} in file of size #{io.stat.size}." io . seek ( seek_to , IO :: SEEK_SET ) return io end
advance the IO forward if it looks like this logfile has already been parsed.
advance the IO forward if it looks like this logfile has already been parsed .
# if the file as a filesize that is less than the offset we would seek to, assume that the  # file should be scanned from the beginning. # now we assume that we are using the same file as before so seek to the appropriate location
io
options