void MusikApp::OnFatalException () { wxDebugReportCompress report; // add all standard files: currently this means just a minidump and an // XML file with system info and stack trace report.AddAll(wxDebugReport::Context_Exception); // create a copy of our preferences file to include it in the report wxFileName destfn(report.GetDirectory(), _T("musik.ini")); wxCopyFile(wxFileConfig::GetLocalFileName(CONFIG_NAME),destfn.GetFullPath()); report.AddFile(destfn.GetFullName(), _T("Current Preferences Settings")); // calling Show() is not mandatory, but is more polite if ( wxDebugReportPreviewStd().Show(report) ) { if ( report.Process() ) { #ifdef USE_WXEMAIL wxMailMessage mail(GetAppName() + _T(" Crash-Report"),_T("*****@*****.**"), MUSIKAPPNAME_VERSION wxT("crashed."), wxEmptyString,report.GetCompressedFileName(),_T("CrashReportZip")); if(!wxEmail::Send(mail)) wxMessageBox(_T("Sending email failed!")); #endif } } //else: user cancelled the report }
void GenerateReport(wxDebugReport::Context ctx) { MyDebugReport report; // add all standard files: currently this means just a minidump and an // XML file with system info and stack trace report.AddAll(ctx); // you can also call report.AddFile(...) with your own log files, files // created using wxRegKey::Export() and so on, here we just add a test // file containing the date of the crash wxFileName fn(report.GetDirectory(), _T("timestamp.my")); wxFFile file(fn.GetFullPath(), _T("w")); if ( file.IsOpened() ) { wxDateTime dt = wxDateTime::Now(); file.Write(dt.FormatISODate() + _T(' ') + dt.FormatISOTime()); file.Close(); } report.AddFile(fn.GetFullName(), _T("timestamp of this report")); // can also add an existing file directly, it will be copied // automatically #ifdef __WXMSW__ report.AddFile(_T("c:\\autoexec.bat"), _T("DOS startup file")); #else report.AddFile(_T("/etc/motd"), _T("Message of the day")); #endif // calling Show() is not mandatory, but is more polite if ( wxDebugReportPreviewStd().Show(report) ) { if ( report.Process() ) { // report successfully uploaded } } //else: user cancelled the report }