增加rjson非0的堆栈日志
This commit is contained in:
parent
83025996b0
commit
c6f565bcdf
@ -156,7 +156,7 @@ def get_imgsrc(imgsrc):
|
|||||||
f.write(out_bytes)
|
f.write(out_bytes)
|
||||||
return send_file(imgsavepath)
|
return send_file(imgsavepath)
|
||||||
else:
|
else:
|
||||||
return ReJson(1001, body=original_img_path)
|
return ReJson(1001, body=f"{original_img_path} not exists")
|
||||||
elif imgsrc.startswith("http://") or imgsrc.startswith("https://"):
|
elif imgsrc.startswith("http://") or imgsrc.startswith("https://"):
|
||||||
# 将?后面的参数连接到imgsrc
|
# 将?后面的参数连接到imgsrc
|
||||||
imgsrc = imgsrc + "?" + request.query_string.decode("utf-8") if request.query_string else imgsrc
|
imgsrc = imgsrc + "?" + request.query_string.decode("utf-8") if request.query_string else imgsrc
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
|
import traceback
|
||||||
|
|
||||||
loger_rjson = logging.getLogger("rjson")
|
loger_rjson = logging.getLogger("rjson")
|
||||||
|
|
||||||
@ -32,12 +34,19 @@ def ReJson(code: int, body: [dict, list] = None, msg: str = None, error: str = N
|
|||||||
9999: {'code': 9999, 'body': body, 'msg': "未知错误!", "extra": extra},
|
9999: {'code': 9999, 'body': body, 'msg': "未知错误!", "extra": extra},
|
||||||
}
|
}
|
||||||
rjson = situation.get(code, {'code': 9999, 'body': None, 'msg': "code错误", "extra": {}})
|
rjson = situation.get(code, {'code': 9999, 'body': None, 'msg': "code错误", "extra": {}})
|
||||||
if code != 0:
|
|
||||||
loger_rjson.warning(f"\n{code=}\nbody=\n{rjson['body']}\nmsg={msg if msg else None}\n")
|
|
||||||
if body:
|
if body:
|
||||||
rjson['body'] = body
|
rjson['body'] = body
|
||||||
if msg:
|
if msg:
|
||||||
rjson['msg'] = msg
|
rjson['msg'] = msg
|
||||||
|
if code != 0:
|
||||||
|
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"])]
|
||||||
|
# 格式化调用栈信息
|
||||||
|
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}")
|
||||||
if error:
|
if error:
|
||||||
loger_rjson.error(error, exc_info=True)
|
loger_rjson.error(error, exc_info=True)
|
||||||
return rjson
|
return rjson
|
||||||
|
Loading…
Reference in New Issue
Block a user