fix 日志首次读取部分数据

This commit is contained in:
jxxghp 2023-08-15 07:12:12 +08:00
parent f460e9a3f1
commit e76606823f

View File

@ -110,8 +110,11 @@ def get_logging(token: str):
)
def log_generator():
log_path = settings.LOG_PATH / 'moviepilot.log'
texts = tailer.tail(open(log_path, 'r'), 50)
while True:
for text in tailer.follow(open(settings.LOG_PATH / 'moviepilot.log')):
yield 'data: %s\n\n' % '\n'.join(texts)
for text in tailer.follow(open(log_path, 'r')):
yield 'data: %s\n\n' % (text or '')
time.sleep(1)