Skip to content

Commit 1097682

Browse files
committed
发生崩溃时同时将崩溃信息写入日志
1 parent e621110 commit 1097682

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

TrafficMonitor/crashtool.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,6 @@ class CCrashReport
142142

143143
void ShowCrashInfo(EXCEPTION_POINTERS* pEP)
144144
{
145-
CMessageDlg dlg;
146-
dlg.SetWindowTitle(APP_NAME);
147-
dlg.SetInfoText(CCommon::LoadText(IDS_ERROR_MESSAGE));
148-
149145
CString info = CCommon::LoadTextFormat(IDS_CRASH_INFO, { m_dumpFile });
150146
info += _T("\r\n");
151147
//在崩溃信息中调用堆栈
@@ -157,7 +153,16 @@ class CCrashReport
157153
info += _T("\r\n");
158154
}
159155
info += theApp.GetSystemInfoString();
160-
dlg.SetMessageText(info);
156+
//写入日志
157+
CString crash_log = info;
158+
crash_log.Replace(_T("\r\n"), _T("\n"));
159+
crash_log.Replace(_T("\n\n"), _T("\n"));
160+
CCommon::WriteLog(crash_log.GetString(), theApp.m_log_path.c_str());
161+
//显示崩溃对话框
162+
CMessageDlg dlg;
163+
dlg.SetWindowTitle(APP_NAME);
164+
dlg.SetInfoText(CCommon::LoadText(IDS_ERROR_MESSAGE));
165+
dlg.SetMessageText(info);
161166
dlg.SetStandarnMessageIcon(CMessageDlg::SI_ERROR);
162167
dlg.DoModal();
163168
}

0 commit comments

Comments
 (0)