mirror of
https://github.com/MeoProject/lx-music-api-server.git
synced 2025-05-23 19:17:41 +08:00
fix: 修复某些时候因错误无法格式化导致程序崩溃的问题
This commit is contained in:
parent
7ea698e147
commit
fa53fdb4e1
@ -84,6 +84,7 @@ def stack_info(stack_trace_line):
|
|||||||
sys.stderr.write(f"日志模块出错,本次日志可能无法记录,请报告给开发者: \n" + traceback.format_exc())
|
sys.stderr.write(f"日志模块出错,本次日志可能无法记录,请报告给开发者: \n" + traceback.format_exc())
|
||||||
|
|
||||||
def highlight_error(e):
|
def highlight_error(e):
|
||||||
|
try:
|
||||||
if (isinstance(e, Exception)):
|
if (isinstance(e, Exception)):
|
||||||
error = stack_error(e)
|
error = stack_error(e)
|
||||||
else:
|
else:
|
||||||
@ -136,6 +137,12 @@ def highlight_error(e):
|
|||||||
# traceback.print_exc()
|
# traceback.print_exc()
|
||||||
final.append(i)
|
final.append(i)
|
||||||
return "\n".join(final).replace('\n\n', '\n')
|
return "\n".join(final).replace('\n\n', '\n')
|
||||||
|
except:
|
||||||
|
logger.error('格式化错误失败,使用默认格式\n' + traceback.format_exc())
|
||||||
|
if (isinstance(e, Exception)):
|
||||||
|
return stack_error(e)
|
||||||
|
else:
|
||||||
|
return e
|
||||||
|
|
||||||
class LogHelper(logging.Handler):
|
class LogHelper(logging.Handler):
|
||||||
# 日志转接器
|
# 日志转接器
|
||||||
|
Loading…
x
Reference in New Issue
Block a user