2025.08.19
This commit is contained in:
parent
c667c70a64
commit
0de0eb5c08
|
|
@ -1,3 +1,6 @@
|
|||
2025.08.19:
|
||||
. Improved log trimming.
|
||||
|
||||
2025.08.18:
|
||||
. Database handling optimization.
|
||||
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
Loading…
Reference in New Issue