xml output

This commit is contained in:
2022-06-05 09:35:11 +08:00
parent 4246e6e9de
commit 427f28bd57
8 changed files with 116 additions and 12 deletions

26
output/debug.py Normal file
View File

@ -0,0 +1,26 @@
import os
import time
import traceback
from output.IOutput import IOutput
class DebugWriter(IOutput):
def other_output(self, message_type: str, message_raw: bytes):
if not os.path.isdir(os.path.join("", "debug")):
os.makedirs(os.path.join("", "debug"))
if not os.path.isdir(os.path.join("", "debug", message_type)):
os.makedirs(os.path.join("", "debug", message_type))
with open(os.path.join("", "debug", message_type, str(time.time())), "wb") as f:
f.write(message_raw)
def error_output(self, message_type: str, message_raw: bytes, exception: Exception):
if not os.path.isdir(os.path.join("", "error")):
os.makedirs(os.path.join("", "error"))
if not os.path.isdir(os.path.join("", "error", message_type)):
os.makedirs(os.path.join("", "error", message_type))
ts = time.time()
with open(os.path.join("", "error", message_type, str(ts)), "wb") as f:
f.write(message_raw)
traceback.print_exc(file=open(os.path.join("", "error", message_type, str(ts)) + ".exc", "w", encoding="UTF-8"))