From b1089b29c833e35225d291a14a53b8f19666dd3a Mon Sep 17 00:00:00 2001 From: Migatu Date: Sat, 6 Apr 2024 02:44:03 +0200 Subject: [PATCH] Fix of the log rotation att 1 --- bot.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bot.py b/bot.py index 47fe6f7..2c49de6 100644 --- a/bot.py +++ b/bot.py @@ -663,6 +663,7 @@ async def check_data(): ) async with channel.typing(): path_newfile = f"{LOGSTORE}{MEMORY_FIVE_MUZYKA[:-4]}{datetime.now()}.json" + logger.info(path_newfile) with open(MEMORY_FIVE_MUZYKA, "r+", encoding=ENCODING) as file_music_memory: with open(path_newfile, "x", encoding=ENCODING) as new_file: # First we load existing data into a dict. @@ -670,6 +671,7 @@ async def check_data(): new_data = [] new_data.append(file_data[0]) new_data.extend(file_data[:-20]) + file_music_memory.truncate(0) file_music_memory.seek(0) # convert back to json. new_file.seek(0) @@ -680,6 +682,7 @@ async def check_data(): ) if os.path.getsize(MEMORY_FIVE_SIARA) > 300000: path_newfile = "{LOGSTORE}{MEMORY_FIVE_SIARA[:-4]}{datetime.now()}.json" + logger.info(path_newfile) await channel.send( "*Conjurer porządkuje bar, ścina lekkim laserem pulsacyjnym powierzchnie baru o grubości kilku mikronów i ogólnie wygląda na zajętego....*" ) @@ -690,6 +693,7 @@ async def check_data(): new_data = [] new_data.append(file_data[0]) new_data.extend(file_data[:-20]) + file.truncate(0) file.seek(0) new_file.seek(0) # convert back to json.