3
I’m trying to make a tool to read and send information (in real time) from a log to my screen.
So far I’ve been able to read everything and send the information line by line and send everything to the screen, follow the code.
import time
count = 0
while True:
arquivo = ('LOG')
arq = open(arquivo, 'r')
texto = arq.readlines()
arq.close()
count += 1
print(texto[count])
time.sleep(5)
The problem is that the program may or may not take long to generate a new line in the log, and when it arrives at the last line, the problem closes with the error.
print(texto[count])
IndexError: list index out of range
How would I make the program, waiting for the new line to be inserted inside the log file?
Being basically the same solution, you could suggest the change through a comment. When you have enough reputation points, you can use them. Until then, try to publish only concrete answers to the problem.
– Woss