Replace report functionality

--HG--
branch : feature-crashreport
This commit is contained in:
kaetemi 2015-03-06 19:06:11 +01:00
parent bbfc15c07a
commit 5a307cfa20
5 changed files with 50 additions and 43 deletions

View file

@ -21,28 +21,38 @@
namespace NLMISC {
enum TReportResult { ReportDebug, ReportIgnore, ReportQuit, ReportError };
#if FINAL_VERSION
#define NL_REPORT_SYNCHRONOUS false
#define NL_REPORT_DEFAULT NLMISC::ReportAbort
#else
#define NL_REPORT_SYNCHRONOUS true
#define NL_REPORT_DEFAULT NLMISC::ReportBreak
#endif
/** Display a custom message box.
enum TReportResult
{
// See also crash_report_widget.h EReturnValue
ReportAlwaysIgnore = 21,
ReportIgnore = 22,
ReportAbort = 23,
ReportBreak = 24
};
/** Display a crash report
*
* \param title set the title of the report. If empty, it'll display "NeL Crash Report" or the default title set by setReportWindowTitle.
* \param header message displayed before the edit text box. If empty, it displays the default message.
* \param body message displayed in the edit text box. This string will be sent by email.
* \param debugButton 0 for disabling it, 1 for enable with default behaviors (generate a breakpoint), 2 for enable with no behavior
* \param title set the title of the report. If empty, it'll display "NeL report"
* \param subject extended title of the report
* \param body message displayed in the edit text box. This string will be sent to the crash report tool
* \param attachment binary file to attach. This is a filename
* \param synchronous use system() and wait for the crash tool exit code, passes -dev flag; otherwise return defaultResult immediately
* \param sendReport hide 'dont send' button, or auto enable 'send report' checkbox
*
*
*
* \return the button clicked or error
* \return the button clicked or defaultResult
*/
TReportResult report(const std::string &title, const std::string &header, const std::string &subject, const std::string &body, bool enableCheckIgnore, uint debugButton, bool ignoreButton, sint quitButton, bool sendReportButton, bool &ignoreNextTime, const std::string &attachedFile = "");
TReportResult report(const std::string &title, const std::string &subject, const std::string &body, const std::string &attachment, bool synchronous, bool sendReport, TReportResult defaultResult);
/// Set the Url of the web service used to post crash reports to
void setReportPostUrl(const std::string &postUrl);
/// DEPRECATED
/** call this in the main of your appli to enable email: setReportEmailFunction (sendEmail);
*/
void setReportEmailFunction(void *emailFunction);
/// Set the Url of the web service used to post crash reports to. String is copied
void setReportPostUrl(const char *postUrl);
} // NLMISC

View file

@ -553,8 +553,8 @@ public:
{
// yoyo: allow only to send the crash report once. Because users usually click ignore,
// which create noise into list of bugs (once a player crash, it will surely continues to do it).
bool i = false;
report (progname+shortExc, "", subject, _Reason, true, 1, true, 1, !isCrashAlreadyReported(), i, NL_CRASH_DUMP_FILE);
report(progname + shortExc, subject, _Reason, NL_CRASH_DUMP_FILE, true, !isCrashAlreadyReported(), ReportAbort);
// TODO: Does this need to be synchronous? Why does this not handle the report result?
// no more sent mail for crash
setCrashAlreadyReported(true);

View file

@ -688,37 +688,33 @@ void CMsgBoxDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *m
// yoyo: allow only to send the crash report once. Because users usually click ignore,
// which create noise into list of bugs (once a player crash, it will surely continues to do it).
std::string filename = getLogDirectory() + NL_CRASH_DUMP_FILE;
TReportResult reportResult = report(args.ProcessName + " NeL " + toString(logTypeToString(args.LogType, true)),
subject, body, filename, NL_REPORT_SYNCHRONOUS, !isCrashAlreadyReported(), NL_REPORT_DEFAULT);
if (ReportDebug == report (args.ProcessName + " NeL " + toString(logTypeToString(args.LogType, true)), "", subject, body, true, 2, true, 1, !isCrashAlreadyReported(), IgnoreNextTime, filename.c_str()))
switch (reportResult)
{
case ReportAlwaysIgnore:
IgnoreNextTime = true;
break;
case ReportBreak:
INelContext::getInstance().setDebugNeedAssert(true);
break;
case ReportAbort:
# ifdef NL_OS_WINDOWS
# ifndef NL_COMP_MINGW
// disable the Windows popup telling that the application aborted and disable the dr watson report.
_set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
# endif
# endif
abort();
break;
}
// no more sent mail for crash
setCrashAlreadyReported(true);
}
/* // Check the envvar NEL_IGNORE_ASSERT
if (getenv ("NEL_IGNORE_ASSERT") == NULL)
{
// Ask the user to continue, debug or ignore
int result = MessageBox (NULL, ss2.str().c_str (), logTypeToString(args.LogType, true), MB_ABORTRETRYIGNORE | MB_ICONSTOP);
if (result == IDABORT)
{
// Exit the program now
exit (EXIT_FAILURE);
}
else if (result == IDRETRY)
{
// Give the debugger a try
DebugNeedAssert = true;
}
else if (result == IDIGNORE)
{
// Continue, do nothing
}
}
*/ }
}
//#endif
}

View file

@ -16,6 +16,7 @@
#include "stdmisc.h"
#include <stdlib.h>
#include <sstream>
#include "nel/misc/common.h"

View file

@ -606,7 +606,7 @@ sint IService::main (const char *serviceShortName, const char *serviceLongName,
ListeningPort = servicePort;
setReportEmailFunction ((void*)sendEmail);
// setReportEmailFunction ((void*)sendEmail);
// setDefaultEmailParams ("gw.nevrax.com", "", "cado@nevrax.com");