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:
|
2025.08.18:
|
||||||
. Database handling optimization.
|
. Database handling optimization.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import collections
|
||||||
import time
|
import time
|
||||||
import credentials
|
import credentials
|
||||||
import sqlite3
|
import sqlite3
|
||||||
|
|
@ -1056,14 +1057,18 @@ class Logger:
|
||||||
self.exchange_name = self.broker_config["exchange"]
|
self.exchange_name = self.broker_config["exchange"]
|
||||||
self.tg_credentials = credentials.get_credentials("telegram")
|
self.tg_credentials = credentials.get_credentials("telegram")
|
||||||
self.log_list_max_length = 10
|
self.log_list_max_length = 10
|
||||||
|
self.log_list = collections.deque(maxlen=self.log_list_max_length)
|
||||||
self.log_list = self.preload_logs()
|
self.log_list = self.preload_logs()
|
||||||
|
|
||||||
|
|
||||||
def preload_logs(self):
|
def preload_logs(self):
|
||||||
try:
|
try:
|
||||||
with open(f"logs/{self.exchange_name}.log","r") as f:
|
with open(f"logs/{self.exchange_name}.log","r") as f:
|
||||||
self.log_list = f.readlines()
|
for line in f:
|
||||||
return self.log_list[-self.log_list_max_length:]
|
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:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
return []
|
return []
|
||||||
|
|
@ -1132,7 +1137,7 @@ class Logger:
|
||||||
self.log_list.append(text)
|
self.log_list.append(text)
|
||||||
|
|
||||||
#Trim log list
|
#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:
|
except Exception as e:
|
||||||
print("Can't write log file")
|
print("Can't write log file")
|
||||||
|
|
|
||||||
2
main.py
2
main.py
|
|
@ -18,7 +18,7 @@ import exchange_wrapper
|
||||||
import trader
|
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
|
Color definitions. If you want to change them, check the reference at https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue