mirror of
https://github.com/LC044/WeChatMsg
synced 2024-11-12 20:21:21 +08:00
新增自动上传错误日志
This commit is contained in:
parent
b4c8498f13
commit
c76f5dde80
@ -2,6 +2,10 @@ import sqlite3
|
|||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
|
import requests
|
||||||
|
|
||||||
|
from app.person import Me
|
||||||
|
|
||||||
|
|
||||||
class ExceptionHanding:
|
class ExceptionHanding:
|
||||||
def __init__(self, exc_type, exc_value, traceback_):
|
def __init__(self, exc_type, exc_value, traceback_):
|
||||||
@ -40,3 +44,30 @@ def excepthook(exc_type, exc_value, traceback_):
|
|||||||
|
|
||||||
# 调用原始的 excepthook,以便程序正常退出
|
# 调用原始的 excepthook,以便程序正常退出
|
||||||
sys.__excepthook__(exc_type, exc_value, traceback_)
|
sys.__excepthook__(exc_type, exc_value, traceback_)
|
||||||
|
|
||||||
|
def send_error_msg( message):
|
||||||
|
url = "http://api.lc044.love/error"
|
||||||
|
if not message:
|
||||||
|
return {
|
||||||
|
'code': 201,
|
||||||
|
'errmsg': '日志为空'
|
||||||
|
}
|
||||||
|
data = {
|
||||||
|
'username': Me().wxid,
|
||||||
|
'error': message
|
||||||
|
}
|
||||||
|
try:
|
||||||
|
response = requests.post(url, json=data)
|
||||||
|
if response.status_code == 200:
|
||||||
|
resp_info = response.json()
|
||||||
|
return resp_info
|
||||||
|
else:
|
||||||
|
return {
|
||||||
|
'code': 503,
|
||||||
|
'errmsg': '服务器错误'
|
||||||
|
}
|
||||||
|
except:
|
||||||
|
return {
|
||||||
|
'code': 404,
|
||||||
|
'errmsg': '客户端错误'
|
||||||
|
}
|
||||||
|
@ -59,7 +59,7 @@ class Me(Person):
|
|||||||
super().__init__()
|
super().__init__()
|
||||||
self.avatar = QPixmap(Icon.Default_avatar_path)
|
self.avatar = QPixmap(Icon.Default_avatar_path)
|
||||||
self.avatar_path = ':/icons/icons/default_avatar.svg'
|
self.avatar_path = ':/icons/icons/default_avatar.svg'
|
||||||
self.wxid = ''
|
self.wxid = 'wxid_00112233'
|
||||||
self.wx_dir = ''
|
self.wx_dir = ''
|
||||||
self.name = ''
|
self.name = ''
|
||||||
self.mobile = ''
|
self.mobile = ''
|
||||||
|
6
main.py
6
main.py
@ -3,7 +3,7 @@ import sys
|
|||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
from app.log.exception_handling import ExceptionHanding
|
from app.log.exception_handling import ExceptionHanding, send_error_msg
|
||||||
from app.ui.Icon import Icon
|
from app.ui.Icon import Icon
|
||||||
|
|
||||||
widget = None
|
widget = None
|
||||||
@ -17,6 +17,8 @@ def excepthook(exc_type, exc_value, traceback_):
|
|||||||
error_message = ExceptionHanding(exc_type, exc_value, traceback_)
|
error_message = ExceptionHanding(exc_type, exc_value, traceback_)
|
||||||
txt = '您可添加QQ群发送log文件以便解决该问题'
|
txt = '您可添加QQ群发送log文件以便解决该问题'
|
||||||
msg = f"Exception Type: {exc_type.__name__}\nException Value: {exc_value}\ndetails: {error_message}\n\n{txt}"
|
msg = f"Exception Type: {exc_type.__name__}\nException Value: {exc_value}\ndetails: {error_message}\n\n{txt}"
|
||||||
|
if SEND_LOG_FLAG:
|
||||||
|
send_error_msg(msg)
|
||||||
logger.error(f'程序发生了错误:\n\n{msg}')
|
logger.error(f'程序发生了错误:\n\n{msg}')
|
||||||
# 创建一个 QMessageBox 对象
|
# 创建一个 QMessageBox 对象
|
||||||
error_box = QMessageBox()
|
error_box = QMessageBox()
|
||||||
@ -49,7 +51,7 @@ from app.DataBase import close_db
|
|||||||
from app.log import logger
|
from app.log import logger
|
||||||
from app.ui import mainview
|
from app.ui import mainview
|
||||||
from app.ui.tool.pc_decrypt import pc_decrypt
|
from app.ui.tool.pc_decrypt import pc_decrypt
|
||||||
from app.config import version
|
from app.config import version, SEND_LOG_FLAG
|
||||||
|
|
||||||
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID("WeChatReport")
|
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID("WeChatReport")
|
||||||
QApplication.setAttribute(Qt.AA_EnableHighDpiScaling, True)
|
QApplication.setAttribute(Qt.AA_EnableHighDpiScaling, True)
|
||||||
|
Loading…
Reference in New Issue
Block a user