Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
784 B
1
Indexable
Never
def update_last_index(syslog_record,last_line_no,i):
    print("The function with update_last_index is getting called.")
    vm_id=i
    bookmark_index=last_line_no
    print("VM ID :",vm_id)
    bookmark_record=syslog_record
    print(f"Bookmark Record for {i} is {bookmark_record}")
    print(f"Updating Bookmark record for {bookmark_record}")
    updated_bookmark_rec= str(bookmark_record) + str(bookmark_index)
    print(updated_bookmark_rec)
    with open(bookmark_file, 'r+') as file:
        lines = file.readlines()
        file.seek(0)
        for line in lines:
            if bookmark_record in line:
                file.write(line.replace(bookmark_record, updated_bookmark_rec))
            else:
                file.write(line)
        file.truncate()