-
Notifications
You must be signed in to change notification settings - Fork 0
/
wxMsDebugRprth.h
109 lines (93 loc) · 3.06 KB
/
wxMsDebugRprth.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*-----------------------------------------------------------------
* Name: wxMsDebugRprth.h
* Purpose:
* Author: A. Wiegert
*
* Copyright: (c) A. Wiegert
* Licence: wxWidgets license
*-------------------------------------------------------------- */
#ifndef _WX_MS_DEBUG_RPRT_H
#define _WX_MS_DEBUG_RPRT_H
#include "wx/app.h"
#include "wx/log.h"
#include "wx/frame.h"
#include "wx/icon.h"
#include "wx/menu.h"
#include "wx/msgdlg.h"
#include "wx/button.h"
#include "wx/dcclient.h"
#include "wx/datetime.h"
#include "wx/ffile.h"
#include "wx/filename.h"
#include "wx/debugrpt.h"
#include "wx/stackwalk.h"
#include "wx/xml/xml.h"
#if !wxUSE_DEBUGREPORT
#error "This sample can't be built without wxUSE_DEBUGREPORT"
#endif // wxUSE_DEBUGREPORT
#if !wxUSE_ON_FATAL_EXCEPTION
#error "This sample can't be built without wxUSE_ON_FATAL_EXCEPTION"
#endif // wxUSE_ON_FATAL_EXCEPTION
// ------------------------------------------------------------------
// ----------------------------------------------------------------------------
// custom debug reporting class
// ----------------------------------------------------------------------------
#if defined( WANT_DBGRPRT )
// this is your custom debug reporter: it will use curl program (which should
// be available) to upload the crash report to the given URL (which should be
// set up by you)
class MyDebugReport : public wxDebugReportUpload
{
public:
MyDebugReport() : wxDebugReportUpload
(
wxT("http://your.url.here/"),
wxT("report:file"),
wxT("action")
)
{
}
protected:
// this is called with the contents of the server response: you will
// probably want to parse the XML document in OnServerReply() instead of
// just dumping it as I do
virtual bool OnServerReply(const wxArrayString& reply)
{
if ( reply.IsEmpty() )
{
wxLogError(wxT("Didn't receive the expected server reply."));
return false;
}
wxString s(wxT("Server replied:\n"));
const size_t count = reply.GetCount();
for ( size_t n = 0; n < count; n++ )
{
s << wxT('\t') << reply[n] << wxT('\n');
}
wxLogMessage(wxT("%s"), s.c_str());
return true;
}
};
WX_CHECK_BUILD_OPTIONS("wxQA")
// ----------------------------------------------------------------------------
// XmlStackWalker: stack walker specialization which dumps stack in XML
// ----------------------------------------------------------------------------
#if wxUSE_STACKWALKER
class XmlStackWalker : public wxStackWalker
{
public:
XmlStackWalker(wxXmlNode *nodeStack)
{
m_isOk = false;
m_nodeStack = nodeStack;
}
bool IsOk() const { return m_isOk; }
protected:
virtual void OnStackFrame(const wxStackFrame& frame);
wxXmlNode *m_nodeStack;
bool m_isOk;
};
#endif
#endif // #if defined( WANT_DBGRPRT )
#endif // _WX_MS_DEBUG_RPRT_H
// ------------------------------- eof ---------------------------