def __init__(self, agent_obj, logfile): job.Job.__init__(self, agent_obj) assert os.path.isfile(logfile), "Not a file: %s" % str(logfile) self._log_size = os.stat(logfile).st_size log.debug("Log size is %d" % self._log_size) self._logfile_path = logfile self._logfile_hndl = open(logfile, 'r') self._progress = 0 # Data read from file self._db = db_interface.getDB()
log.debug("Finished reading %d lines (%d bytes), returning %d" % (num_lines, bytes_read, line_count)) return bytes_read if __name__ == '__main__': log_hndler = logging.StreamHandler() log_fmt = logging.Formatter(logging.BASIC_FORMAT) log_hndler.setFormatter(log_fmt) log.addHandler(log_hndler) log.setLevel(logging.DEBUG) if len(sys.argv) < 2: log.error("Log file not specified") sys.exit(1) logfile = sys.argv[1] log.info("Reading logfile %s" % logfile) hndl = open(logfile, 'r') db = db_interface.getDB() stop = False while not stop: try: bytes = read_log(hndl, db, 2) log.debug("Finished reading %d bytes" % bytes) except EndOfLogException, e: log.info("Finished reading log") stop = True