|
@ -207,7 +207,7 @@ class Message: |
|
|
|
|
|
|
|
|
def getLogLevel(self, tool="", comp=None): |
|
|
def getLogLevel(self, tool="", comp=None): |
|
|
""" |
|
|
""" |
|
|
gets the decreasing level depending on tool and component |
|
|
gets the increasing level depending on tool and component |
|
|
if these arguments matches with a job-parameter the level decreases |
|
|
if these arguments matches with a job-parameter the level decreases |
|
|
:param tool: |
|
|
:param tool: |
|
|
:param comp: |
|
|
:param comp: |
|
@ -244,8 +244,13 @@ class Message: |
|
|
else: |
|
|
else: |
|
|
return False |
|
|
return False |
|
|
|
|
|
|
|
|
|
|
|
def getFinalReturncode(self): |
|
|
|
|
|
RETURN_TEXT = ["OK", "WARN", "ERROR", "FATAL"] |
|
|
|
|
|
return RETURN_TEXT[self.rc] |
|
|
|
|
|
|
|
|
def getFinalRc(self): |
|
|
def getFinalRc(self): |
|
|
return int(int(self.rc)) |
|
|
RETURN_TEXT = ["OK", "WARN", "ERROR", "FATAL"] |
|
|
|
|
|
return int(self.rc) |
|
|
|
|
|
|
|
|
def setFatal(self, text): |
|
|
def setFatal(self, text): |
|
|
""" Routine zum Setzen des RC und gleichzeitigem Schreiben des Logs """ |
|
|
""" Routine zum Setzen des RC und gleichzeitigem Schreiben des Logs """ |
|
@ -365,33 +370,86 @@ class Message: |
|
|
self.debug(LIMIT_XTRACE, prio, text) |
|
|
self.debug(LIMIT_XTRACE, prio, text) |
|
|
|
|
|
|
|
|
def getLoggingArgs(self, mlevel, prio, text): |
|
|
def getLoggingArgs(self, mlevel, prio, text): |
|
|
|
|
|
verify = self.getLogLevel("msg_tool") |
|
|
|
|
|
self.logTrace(verify, "getLoggingArgs: " + str(mlevel)+ ", "+self.format2Str(prio)+", "+self.format2Str(text)) |
|
|
out = {} |
|
|
out = {} |
|
|
|
|
|
prefix = "" |
|
|
if isinstance(mlevel, int): |
|
|
if isinstance(mlevel, int): |
|
|
out["mlevel"] = mlevel |
|
|
out["mlevel"] = mlevel |
|
|
else: |
|
|
else: |
|
|
raise Exception("argument mlevel is not int "+str(mlevel)) |
|
|
raise Exception("argument mlevel is not int "+str(mlevel)) |
|
|
a = text.split(":") |
|
|
if len(text) < 1: |
|
|
cat = "" |
|
|
|
|
|
txt = "" |
|
|
|
|
|
if len(a[0]) > 1 and a[0].lower() in LIST_MTEXT: |
|
|
|
|
|
cat = a[0] |
|
|
|
|
|
if len(a) > 1 and len(a[1]) > 1: |
|
|
|
|
|
txt = a[1] |
|
|
|
|
|
elif len(a[0]) > 1 and a[0].lower() not in LIST_MTEXT: |
|
|
|
|
|
txt = a[0] |
|
|
|
|
|
if isinstance(prio, int) and len(txt) > 1: |
|
|
|
|
|
out["mprio"] = prio |
|
|
|
|
|
elif len(txt) < 1 and isinstance(prio, str): |
|
|
|
|
|
txt = prio |
|
|
|
|
|
out["mprio"] = 0 |
|
|
out["mprio"] = 0 |
|
|
if len(txt) < 1: |
|
|
if isinstance(prio, int): |
|
|
raise Exception("argument text is not fount " + str(mlevel) + ", " + str(prio) + ", " + str(text)) |
|
|
txt = str(prio) |
|
|
if len(cat) > 1: |
|
|
elif isinstance(prio, dict): |
|
|
out["mtext"] = cat + ": " + txt |
|
|
txt = self.formatDict2Str(prio) |
|
|
|
|
|
elif isinstance(prio, str): |
|
|
|
|
|
txt = prio |
|
|
|
|
|
elif isinstance(prio, list): |
|
|
|
|
|
txt = self.formatList2Str(prio) |
|
|
|
|
|
else: |
|
|
|
|
|
txt = str(prio) |
|
|
|
|
|
else: |
|
|
|
|
|
if isinstance(prio, int): |
|
|
|
|
|
out["mprio"] = prio |
|
|
|
|
|
else: |
|
|
|
|
|
out["mprio"] = 0 |
|
|
|
|
|
prefix = text |
|
|
|
|
|
text = prio |
|
|
|
|
|
if isinstance(text, dict): |
|
|
|
|
|
txt = self.formatDict2Str(text) |
|
|
|
|
|
elif isinstance(text, str): |
|
|
|
|
|
txt = text |
|
|
|
|
|
elif isinstance(text, list): |
|
|
|
|
|
txt = self.formatList2Str(text) |
|
|
|
|
|
else: |
|
|
|
|
|
txt = str(text) |
|
|
|
|
|
if len(prefix) > 1: |
|
|
|
|
|
if ":" in prefix: |
|
|
|
|
|
out["mtext"] = prefix.strip() + " " + txt.strip() |
|
|
|
|
|
else: |
|
|
|
|
|
out["mtext"] = prefix.strip() + ": " + txt.strip() |
|
|
else: |
|
|
else: |
|
|
out["mtext"] = txt |
|
|
out["mtext"] = txt |
|
|
return out |
|
|
return out |
|
|
|
|
|
|
|
|
|
|
|
def format2Str(self, elem): |
|
|
|
|
|
if isinstance(elem, dict): |
|
|
|
|
|
return self.formatDict2Str(elem) |
|
|
|
|
|
elif isinstance(elem, str): |
|
|
|
|
|
return elem |
|
|
|
|
|
elif isinstance(elem, list): |
|
|
|
|
|
return self.formatList2Str(elem) |
|
|
|
|
|
else: |
|
|
|
|
|
return str(elem) |
|
|
|
|
|
|
|
|
|
|
|
def formatDict2Str(self, args): |
|
|
|
|
|
txt = "{" |
|
|
|
|
|
for k in args: |
|
|
|
|
|
if isinstance(args[k], dict): |
|
|
|
|
|
txt += k + ": " + self.formatDict2Str(args[k]) + ", " |
|
|
|
|
|
elif isinstance(args[k], str): |
|
|
|
|
|
txt += k + ": " + args[k] + ", " |
|
|
|
|
|
elif isinstance(args[k], list): |
|
|
|
|
|
txt += k + ": " + self.formatList2Str(args[k]) + ", " |
|
|
|
|
|
else: |
|
|
|
|
|
txt += k + ": " + str(args[k]) + ", " |
|
|
|
|
|
return txt[0:-2] + "}" |
|
|
|
|
|
|
|
|
|
|
|
def formatList2Str(self, args): |
|
|
|
|
|
txt = "[" |
|
|
|
|
|
for k in args: |
|
|
|
|
|
if isinstance(k, dict): |
|
|
|
|
|
txt += k + ": {" + self.formatDict2Str(k) + "}, " |
|
|
|
|
|
elif isinstance(k, str): |
|
|
|
|
|
txt += k + ", " |
|
|
|
|
|
elif isinstance(k, list): |
|
|
|
|
|
txt += self.formatList2Str(k) + ", " |
|
|
|
|
|
else: |
|
|
|
|
|
txt += str(k) + ", " |
|
|
|
|
|
return txt[0:-2] + "]" |
|
|
|
|
|
|
|
|
def log(self, mlevel, prio, text): |
|
|
def log(self, mlevel, prio, text): |
|
|
args = self.getLoggingArgs(mlevel, prio, text) |
|
|
args = self.getLoggingArgs(mlevel, prio, text) |
|
|
""" eigentliche Schreibroutine: hierin wird debug-Level beruecksichtgigt""" |
|
|
""" eigentliche Schreibroutine: hierin wird debug-Level beruecksichtgigt""" |
|
@ -406,8 +464,11 @@ class Message: |
|
|
self.messages.append(text) |
|
|
self.messages.append(text) |
|
|
|
|
|
|
|
|
def debug(self, mlevel, prio, text=""): |
|
|
def debug(self, mlevel, prio, text=""): |
|
|
|
|
|
verify = self.getLogLevel("msg_tool") |
|
|
args = self.getLoggingArgs(mlevel, prio, text) |
|
|
args = self.getLoggingArgs(mlevel, prio, text) |
|
|
if (args["mlevel"] + args["mprio"] > int(self.level)): |
|
|
if verify: |
|
|
|
|
|
self.debugfile.write("m.debug "+self.format2Str(args)+" >? "+str(self.level)+"\n") |
|
|
|
|
|
if (args["mlevel"] - args["mprio"] > int(self.level)): |
|
|
return |
|
|
return |
|
|
if (args["mprio"] + 20) % 2 == 1: |
|
|
if (args["mprio"] + 20) % 2 == 1: |
|
|
print(args["mtext"]) |
|
|
print(args["mtext"]) |
|
|