mirror of
https://github.com/ThomasGsp/HyperProxmox.git
synced 2025-03-09 15:40:18 +00:00
fix logger issues
This commit is contained in:
parent
38e5ba88ce
commit
5aa39af9c0
1 changed files with 9 additions and 8 deletions
|
@ -29,22 +29,23 @@ class Logger:
|
|||
|
||||
lKeyC = [key for key, value in switcher.items() if '"{val}"'.format(val=value) == json.dumps(json_text["result"])][0]
|
||||
|
||||
if lKeyC >= self.log_level and lKeyC <= 4:
|
||||
if lKeyC >= self.log_level or self.log_level == 5:
|
||||
|
||||
now = datetime.datetime.now()
|
||||
date = now.strftime("%Y-%m-%d %H:%M")
|
||||
newtext = re.sub(r"ticket\?(.*?) ", "ticket?username=***YOUR_USER***&password=***PWD***", json_text["value"])
|
||||
newtext = re.sub(r"ticket\?(.*?) ", "ticket?username=***YOUR_USER***&password=***PWD***", json.dumps(json_text["value"]))
|
||||
|
||||
try:
|
||||
info = "[{0}] [{1}] [{2}]".format(json_text["result"], json_text["type"], json_text["target"])
|
||||
info = "[{3}] [{0}] [{1}] [{2}]".format(json_text["result"], json_text["type"], json_text["target"], json_text["thread"])
|
||||
except BaseException:
|
||||
info = "[{0}] [{1}]".format(json_text["result"], json_text["type"])
|
||||
info = "[{2}] [{0}] [{1}]".format(json_text["result"], json_text["type"], json_text["thread"])
|
||||
|
||||
newtext = "[{date}] {info} : {text} \n".format(date=date, info=info, text=newtext)
|
||||
|
||||
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:
|
||||
if getsizeof(self.currenttext_proxmox) > 800 or self.bulk == 0 or self.log_level == 5:
|
||||
errorlog = open("{0}/proxmox.log".format(self.logs_dir), "ab")
|
||||
errorlog.write(self.currenttext_proxmox.encode('utf-8'))
|
||||
self.currenttext_proxmox = ""
|
||||
|
@ -52,7 +53,7 @@ class Logger:
|
|||
|
||||
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:
|
||||
if getsizeof(self.currenttext_hyperproxmox) > 800 or self.bulk == 0 or self.log_level == 5:
|
||||
errorlog = open("{0}/hyperproxmox.log".format(self.logs_dir), "ab")
|
||||
errorlog.write(self.currenttext_hyperproxmox.encode('utf-8'))
|
||||
self.currenttext_hyperproxmox = ""
|
||||
|
@ -60,14 +61,14 @@ class Logger:
|
|||
|
||||
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:
|
||||
if getsizeof(self.currenttext_python) > 800 or self.bulk == 0 or self.log_level == 5:
|
||||
errorlog = open("{0}/python.log".format(self.logs_dir), "ab")
|
||||
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:
|
||||
if getsizeof(self.currenttext_others) > 800 or self.bulk == 0 or self.log_level == 5:
|
||||
errorlog = open("{0}/others.log".format(self.logs_dir), "ab")
|
||||
errorlog.write(self.currenttext_others.encode('utf-8'))
|
||||
self.currenttext_others = ""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue