KiCad PCB EDA Suite
Loading...
Searching...
No Matches
app_monitor.h
Go to the documentation of this file.
1
/*
2
* This program source code file is part of KiCad, a free EDA CAD application.
3
*
4
* Copyright The KiCad Developers, see AUTHORS.TXT for contributors.
5
*
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, you may find one here:
18
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19
* or you may search the http://www.gnu.org website for the version 2 license,
20
* or you may write to the Free Software Foundation, Inc.,
21
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22
*/
23
24
#pragma once
25
26
#include <
kicommon.h
>
27
#include <string>
28
#include <set>
29
#include <wx/string.h>
30
#include <wx/filename.h>
31
32
namespace
APP_MONITOR
33
{
34
enum class
BREADCRUMB_TYPE
35
{
36
DEFAULT
,
37
DBG
,
38
ERR
,
39
NAVIGATION
,
40
INFO
,
41
QUERY
,
42
TRANSACTION
,
43
UI
,
44
USER
,
45
};
46
47
enum class
BREADCRUMB_LEVEL
48
{
49
FATAL
,
50
ERR
,
51
WARNING
,
52
INFO
,
53
DBG
54
};
55
56
class
TRANSACTION_IMPL;
57
63
class
KICOMMON_API
TRANSACTION
64
{
65
public
:
66
TRANSACTION
(
const
std::string& aName,
const
std::string& aOperation );
67
~TRANSACTION
();
68
69
void
Start();
70
void
StartSpan(
const
std::string& aOperation,
const
std::string& aDescription );
71
void
FinishSpan();
72
void
Finish();
73
74
#ifdef KICAD_USE_SENTRY
75
private
:
76
// We use a IMPL to avoid seeding sentry everywhere
77
TRANSACTION_IMPL* m_impl =
nullptr
;
78
#endif
79
};
80
89
struct
KICOMMON_API
ASSERT_CACHE_KEY
90
{
91
wxString
file
;
92
int
line
;
93
wxString
func
;
94
wxString
cond
;
95
};
96
97
KICOMMON_API
98
bool
operator<
(
const
ASSERT_CACHE_KEY
& aKey1,
const
ASSERT_CACHE_KEY
& aKey2 );
99
107
class
KICOMMON_API
SENTRY
108
{
109
public
:
110
SENTRY
(
const
SENTRY
& obj ) =
delete
;
111
112
static
SENTRY
*
Instance
()
113
{
114
if
( m_instance ==
nullptr
)
115
m_instance =
new
SENTRY
();
116
117
return
m_instance;
118
}
119
120
void
Init();
121
void
Cleanup();
122
123
bool
IsOptedIn();
124
void
AddTag(
const
wxString& aKey,
const
wxString& aValue );
125
void
SetSentryOptIn(
bool
aOptIn );
126
const
wxString& GetSentryId();
127
void
ResetSentryId();
128
129
void
LogAssert(
const
ASSERT_CACHE_KEY
& aKey,
const
wxString& aMsg );
130
void
LogException(
const
wxString& aMsg );
131
132
private
:
133
SENTRY
();
134
135
bool
isConfiguredOptedIn();
136
void
sentryInit();
137
wxString sentryCreateUid();
138
void
readOrCreateUid();
139
140
static
SENTRY
*
m_instance
;
141
142
bool
m_isOptedIn
;
143
wxFileName
m_sentry_optin_fn
;
144
wxFileName
m_sentry_uid_fn
;
145
wxString
m_sentryUid
;
146
147
std::set<ASSERT_CACHE_KEY>
m_assertCache
;
148
};
149
153
KICOMMON_API
void
AddBreadcrumb
(
BREADCRUMB_TYPE
aType,
const
wxString& aMsg,
const
wxString& aCategory,
154
BREADCRUMB_LEVEL
aLevel =
BREADCRUMB_LEVEL::INFO
);
155
156
160
KICOMMON_API
void
AddNavigationBreadcrumb
(
const
wxString& aMsg,
const
wxString& aCategory );
161
162
166
KICOMMON_API
void
AddTransactionBreadcrumb
(
const
wxString& aMsg,
const
wxString& aCategory );
167
}
APP_MONITOR::SENTRY
This is a singleton class intended to manage sentry.
Definition:
app_monitor.h:108
APP_MONITOR::SENTRY::m_assertCache
std::set< ASSERT_CACHE_KEY > m_assertCache
Definition:
app_monitor.h:147
APP_MONITOR::SENTRY::m_sentry_uid_fn
wxFileName m_sentry_uid_fn
Definition:
app_monitor.h:144
APP_MONITOR::SENTRY::m_sentryUid
wxString m_sentryUid
Definition:
app_monitor.h:145
APP_MONITOR::SENTRY::SENTRY
SENTRY(const SENTRY &obj)=delete
APP_MONITOR::SENTRY::m_isOptedIn
bool m_isOptedIn
Definition:
app_monitor.h:142
APP_MONITOR::SENTRY::m_instance
static SENTRY * m_instance
Definition:
app_monitor.h:140
APP_MONITOR::SENTRY::m_sentry_optin_fn
wxFileName m_sentry_optin_fn
Definition:
app_monitor.h:143
APP_MONITOR::SENTRY::Instance
static SENTRY * Instance()
Definition:
app_monitor.h:112
APP_MONITOR::TRANSACTION
This represents a sentry transaction which is used for time-performance metrics You start a transacti...
Definition:
app_monitor.h:64
kicommon.h
KICOMMON_API
#define KICOMMON_API
Definition:
kicommon.h:28
APP_MONITOR
Definition:
app_monitor.cpp:311
APP_MONITOR::AddTransactionBreadcrumb
void AddTransactionBreadcrumb(const wxString &aMsg, const wxString &aCategory)
Add a transaction breadcrumb.
Definition:
app_monitor.cpp:353
APP_MONITOR::BREADCRUMB_TYPE
BREADCRUMB_TYPE
Definition:
app_monitor.h:35
APP_MONITOR::BREADCRUMB_TYPE::USER
@ USER
APP_MONITOR::BREADCRUMB_TYPE::INFO
@ INFO
APP_MONITOR::BREADCRUMB_TYPE::QUERY
@ QUERY
APP_MONITOR::BREADCRUMB_TYPE::NAVIGATION
@ NAVIGATION
APP_MONITOR::BREADCRUMB_TYPE::DEFAULT
@ DEFAULT
APP_MONITOR::BREADCRUMB_TYPE::UI
@ UI
APP_MONITOR::BREADCRUMB_TYPE::DBG
@ DBG
APP_MONITOR::BREADCRUMB_TYPE::ERR
@ ERR
APP_MONITOR::BREADCRUMB_LEVEL
BREADCRUMB_LEVEL
Definition:
app_monitor.h:48
APP_MONITOR::BREADCRUMB_LEVEL::WARNING
@ WARNING
APP_MONITOR::BREADCRUMB_LEVEL::FATAL
@ FATAL
APP_MONITOR::BREADCRUMB_LEVEL::INFO
@ INFO
APP_MONITOR::AddBreadcrumb
void AddBreadcrumb(BREADCRUMB_TYPE aType, const wxString &aMsg, const wxString &aCategory, BREADCRUMB_LEVEL aLevel)
Add a sentry breadcrumb.
Definition:
app_monitor.cpp:321
APP_MONITOR::AddNavigationBreadcrumb
void AddNavigationBreadcrumb(const wxString &aMsg, const wxString &aCategory)
Add a navigation breadcrumb.
Definition:
app_monitor.cpp:345
APP_MONITOR::operator<
bool operator<(const ASSERT_CACHE_KEY &aKey1, const ASSERT_CACHE_KEY &aKey2)
Definition:
app_monitor.cpp:315
APP_MONITOR::ASSERT_CACHE_KEY
This struct represents a key being used for the std::set that deduplicates asserts during this runnin...
Definition:
app_monitor.h:90
APP_MONITOR::ASSERT_CACHE_KEY::func
wxString func
Definition:
app_monitor.h:93
APP_MONITOR::ASSERT_CACHE_KEY::cond
wxString cond
Definition:
app_monitor.h:94
APP_MONITOR::ASSERT_CACHE_KEY::line
int line
Definition:
app_monitor.h:92
APP_MONITOR::ASSERT_CACHE_KEY::file
wxString file
Definition:
app_monitor.h:91
src
include
app_monitor.h
Generated on Wed Jul 9 2025 00:05:23 for KiCad PCB EDA Suite by
1.9.6