Fix of the log rotation att 1

This commit is contained in:
2024-04-06 02:44:03 +02:00
parent 5b69ed6e1d
commit b1089b29c8
+4
View File
@@ -663,6 +663,7 @@ async def check_data():
) )
async with channel.typing(): async with channel.typing():
path_newfile = f"{LOGSTORE}{MEMORY_FIVE_MUZYKA[:-4]}{datetime.now()}.json" 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(MEMORY_FIVE_MUZYKA, "r+", encoding=ENCODING) as file_music_memory:
with open(path_newfile, "x", encoding=ENCODING) as new_file: with open(path_newfile, "x", encoding=ENCODING) as new_file:
# First we load existing data into a dict. # First we load existing data into a dict.
@@ -670,6 +671,7 @@ async def check_data():
new_data = [] new_data = []
new_data.append(file_data[0]) new_data.append(file_data[0])
new_data.extend(file_data[:-20]) new_data.extend(file_data[:-20])
file_music_memory.truncate(0)
file_music_memory.seek(0) file_music_memory.seek(0)
# convert back to json. # convert back to json.
new_file.seek(0) new_file.seek(0)
@@ -680,6 +682,7 @@ async def check_data():
) )
if os.path.getsize(MEMORY_FIVE_SIARA) > 300000: if os.path.getsize(MEMORY_FIVE_SIARA) > 300000:
path_newfile = "{LOGSTORE}{MEMORY_FIVE_SIARA[:-4]}{datetime.now()}.json" path_newfile = "{LOGSTORE}{MEMORY_FIVE_SIARA[:-4]}{datetime.now()}.json"
logger.info(path_newfile)
await channel.send( 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....*" "*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 = []
new_data.append(file_data[0]) new_data.append(file_data[0])
new_data.extend(file_data[:-20]) new_data.extend(file_data[:-20])
file.truncate(0)
file.seek(0) file.seek(0)
new_file.seek(0) new_file.seek(0)
# convert back to json. # convert back to json.