From 9f5f74c45635090d7a195ef515f3c47b44b06a75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juhani=20Krekel=C3=A4?= Date: Sun, 12 Dec 2021 17:07:00 +0200 Subject: [PATCH] Flush log output after each line in case output is buffered --- ircbot.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ircbot.py b/ircbot.py index e964149..7ec5f50 100644 --- a/ircbot.py +++ b/ircbot.py @@ -42,6 +42,7 @@ class LoggerThread(threading.Thread): if message_data[0] == internal_submessage_types.quit: assert len(message_data) == 1 print('--- Quit') + sys.stdout.flush() self.dead_notify_channel.send((controlmessage_types.quit,)) break @@ -49,23 +50,28 @@ class LoggerThread(threading.Thread): elif message_data[0] == internal_submessage_types.error: assert len(message_data) == 2 print('--- Error', message_data[1]) + sys.stdout.flush() elif message_data[0] == internal_submessage_types.server: assert len(message_data) == 2 assert len(message_data[1]) == 2 print(f'--- Connecting to server {message_data[1][0]}:{message_data[1][1]}') + sys.stdout.flush() else: print('--- ???', message_data) + sys.stdout.flush() # Messages about status from the bot code elif message_type == logmessage_types.status: assert len(message_data) == 2 print('*', end='') print(*message_data[0], **message_data[1]) + sys.stdout.flush() else: print('???', message_type, message_data) + sys.stdout.flush() # API(serverthread_object) # Create a new API object corresponding to given ServerThread object