2025.08.19

This commit is contained in:
Nicolás Sánchez 2025-08-19 11:42:31 -03:00
parent c667c70a64
commit 0de0eb5c08
3 changed files with 12 additions and 4 deletions

View File

@ -1,3 +1,6 @@
2025.08.19:
. Improved log trimming.
2025.08.18:
. Database handling optimization.

View File

@ -1,3 +1,4 @@
import collections
import time
import credentials
import sqlite3
@ -1056,14 +1057,18 @@ class Logger:
self.exchange_name = self.broker_config["exchange"]
self.tg_credentials = credentials.get_credentials("telegram")
self.log_list_max_length = 10
self.log_list = collections.deque(maxlen=self.log_list_max_length)
self.log_list = self.preload_logs()
def preload_logs(self):
try:
with open(f"logs/{self.exchange_name}.log","r") as f:
self.log_list = f.readlines()
return self.log_list[-self.log_list_max_length:]
for line in f:
self.log_list.append(line.rstrip("\n"))
# self.log_list = f.readlines()
#return self.log_list[-self.log_list_max_length:]
return list(self.log_list)
except Exception as e:
print(e)
return []
@ -1132,7 +1137,7 @@ class Logger:
self.log_list.append(text)
#Trim log list
self.log_list = self.log_list[-self.log_list_max_length:]
#self.log_list = self.log_list[-self.log_list_max_length:]
except Exception as e:
print("Can't write log file")

View File

@ -18,7 +18,7 @@ import exchange_wrapper
import trader
version = "2025.08.18"
version = "2025.08.19"
'''
Color definitions. If you want to change them, check the reference at https://en.wikipedia.org/wiki/ANSI_escape_code#Colors