This commit is contained in:
Mark Qvist 2026-04-25 17:56:54 +02:00
commit e592244443

View file

@ -149,14 +149,10 @@ def log(msg, level=3, _override_destination = False, pt=False):
elif (logdest == LOG_FILE and logfile != None):
try:
file = open(logfile, "a")
file.write(logstring+"\n")
file.close()
with open(logfile, "a") as file: file.write(logstring+"\n")
if os.path.getsize(logfile) > LOG_MAXSIZE:
prevfile = logfile+".1"
if os.path.isfile(prevfile):
os.unlink(prevfile)
if os.path.isfile(prevfile): os.unlink(prevfile)
os.rename(logfile, prevfile)
except Exception as e:
@ -166,8 +162,7 @@ def log(msg, level=3, _override_destination = False, pt=False):
log(msg, level)
elif logdest == LOG_CALLBACK:
try:
logcall(logstring)
try: logcall(logstring)
except Exception as e:
_always_override_destination = True
log("Exception occurred while calling external log handler: "+str(e), LOG_CRITICAL)