增加rjson非0的堆栈日志

This commit is contained in:
xaoyaoo 2024-08-03 20:35:57 +08:00
parent c6f565bcdf
commit c26682e19b
3 changed files with 3 additions and 4 deletions

View File

@ -42,11 +42,11 @@ def ReJson(code: int, body: [dict, list] = None, msg: str = None, error: str = N
stack = traceback.extract_stack()
project_stack = [frame for frame in stack if "pywxdump" in frame.filename.lower() and
any(keyword in frame.filename for keyword in
["api", "db", "wx_core", "analyzer", "ui"])]
["api", "db", "wx_core", "analyzer", "ui", "cli", "server"])]
# 格式化调用栈信息
formatted_stack = ''.join(traceback.format_list(project_stack))
# stack_trace = ''.join(traceback.format_stack())
loger_rjson.warning(f"\n{code=}\nbody=\n{rjson['body']}\nmsg={rjson['msg']}\n{extra=}\n{formatted_stack}")
loger_rjson.warning(f"\n{code=}\n{rjson['body']=}\n{rjson['msg']=}\n{rjson['extra']=}\n{formatted_stack}")
if error:
loger_rjson.error(error, exc_info=True)
return rjson

View File

@ -99,7 +99,7 @@ def error9999(func):
traceback_data = traceback.format_exc()
rdata = f"{traceback_data}"
# logging.error(rdata)
return ReJson(9999, body=rdata)
return ReJson(9999, body=f"{str(e)}\n{rdata}", error=str(e))
return wrapper

View File

@ -124,7 +124,6 @@ class DatabaseBase(DatabaseSingletonBase):
finally:
connection.close()
def check_tables_exist(self, required_tables):
"""
判断该类所需要的表是否存在