mirror of
https://github.com/ThomasGsp/HyperProxmox.git
synced 2025-03-09 15:40:18 +00:00
- Fix bulk: mix type of logs
This commit is contained in:
parent
f67a6463ad
commit
0392262277
1 changed files with 36 additions and 17 deletions
|
@ -92,7 +92,10 @@ class Logger2:
|
|||
self.log_level = int(loggerconf['logs_level'])
|
||||
self.bulk = loggerconf['bulk_write']
|
||||
self.bulk_size = loggerconf['bulk_size']
|
||||
self.currenttext = ""
|
||||
self.currenttext_proxmox = ""
|
||||
self.currenttext_hyperproxmox = ""
|
||||
self.currenttext_python = ""
|
||||
self.currenttext_others = ""
|
||||
|
||||
def write(self, json_text):
|
||||
switcher = {
|
||||
|
@ -116,24 +119,40 @@ class Logger2:
|
|||
info = "[{0}] [{1}]".format(json_text["result"], json_text["type"])
|
||||
|
||||
newtext = "[{date}] {info} : {text} \n".format(date=date, info=info, text=newtext)
|
||||
self.currenttext = self.currenttext + newtext
|
||||
|
||||
if getsizeof(self.currenttext) > 800 or self.bulk == 0 or self.log_level == 6:
|
||||
try:
|
||||
if json_text["type"] == "PROXMOX":
|
||||
try:
|
||||
if json_text["type"] == "PROXMOX":
|
||||
self.currenttext_proxmox = self.currenttext_proxmox + newtext
|
||||
if getsizeof(self.currenttext_proxmox) > 800 or self.bulk == 0 or self.log_level == 6:
|
||||
errorlog = open("{0}/proxmox.log".format(self.logs_dir), "ab")
|
||||
errorlog.write(self.currenttext.encode('utf-8'))
|
||||
elif json_text["type"] == "HYPERPROXMOX":
|
||||
errorlog.write(self.currenttext_proxmox.encode('utf-8'))
|
||||
self.currenttext_proxmox = ""
|
||||
errorlog.close()
|
||||
|
||||
elif json_text["type"] == "HYPERPROXMOX":
|
||||
self.currenttext_hyperproxmox = self.currenttext_hyperproxmox + newtext
|
||||
if getsizeof(self.currenttext_hyperproxmox) > 800 or self.bulk == 0 or self.log_level == 6:
|
||||
errorlog = open("{0}/hyperproxmox.log".format(self.logs_dir), "ab")
|
||||
errorlog.write(self.currenttext.encode('utf-8'))
|
||||
elif json_text["type"] == "PYTHON":
|
||||
errorlog.write(self.currenttext_hyperproxmox.encode('utf-8'))
|
||||
self.currenttext_hyperproxmox = ""
|
||||
errorlog.close()
|
||||
|
||||
elif json_text["type"] == "PYTHON":
|
||||
self.currenttext_python = self.currenttext_python + newtext
|
||||
if getsizeof(self.currenttext_python) > 800 or self.bulk == 0 or self.log_level == 6:
|
||||
errorlog = open("{0}/python.log".format(self.logs_dir), "ab")
|
||||
errorlog.write(self.currenttext.encode('utf-8'))
|
||||
else:
|
||||
errorlog.write(self.currenttext_python.encode('utf-8'))
|
||||
self.currenttext_python = ""
|
||||
errorlog.close()
|
||||
else:
|
||||
self.currenttext_others = self.currenttext_others + newtext
|
||||
if getsizeof(self.currenttext_others) > 800 or self.bulk == 0 or self.log_level == 6:
|
||||
errorlog = open("{0}/others.log".format(self.logs_dir), "ab")
|
||||
errorlog.write(self.currenttext.encode('utf-8'))
|
||||
errorlog.close()
|
||||
self.currenttext = ""
|
||||
except BaseException:
|
||||
print("Cannot write on {0}, please check permissions.".format(self.logs_dir))
|
||||
exit(1)
|
||||
errorlog.write(self.currenttext_others.encode('utf-8'))
|
||||
self.currenttext_others = ""
|
||||
errorlog.close()
|
||||
|
||||
|
||||
except BaseException:
|
||||
print("Cannot write on {0}, please check permissions.".format(self.logs_dir))
|
||||
exit(1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue