Skip to content

Commit 00efcc2

Browse files
committed
added FunctionInfo
1 parent 95a99bd commit 00efcc2

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

source/gameanalytics/GAUtilities.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,9 @@ namespace gameanalytics
7373
return defValue;
7474
}
7575

76-
std::pair<std::string, int32_t> getRelevantFunctionFromCallStack()
76+
FunctionInfo getRelevantFunctionFromCallStack()
7777
{
78-
std::string function;
79-
int32_t line = -1;
78+
FunctionInfo funcInfo;
8079

8180
try
8281
{
@@ -89,19 +88,19 @@ namespace gameanalytics
8988
f.find("call_stack") == std::string::npos &&
9089
f.find("getRelevantFunctionFromCallStack") == std::string::npos)
9190
{
92-
function = f;
93-
line = entry.line;
91+
funcInfo.functionName = f;
92+
funcInfo.lineNumber = entry.line;
9493
break;
9594
}
9695
}
9796
}
9897
catch(...)
9998
{
100-
function = "";
101-
line = -1;
99+
funcInfo.functionName = "";
100+
funcInfo.lineNumber = -1;
102101
}
103102

104-
return std::make_pair(function, line);
103+
return funcInfo;
105104
}
106105

107106
// Compress a STL string using zlib with given compression level and return the binary data.
@@ -388,6 +387,7 @@ namespace gameanalytics
388387
return true;
389388
#endif
390389
}
390+
391391
}
392392

393393
std::vector<uint8_t> GAUtilities::gzipCompress(const char* data)

source/gameanalytics/GAUtilities.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,13 @@ namespace gameanalytics
118118
std::string printArray(const StringVector& v, std::string const& delimiter = ", ");
119119
int64_t getNumberFromCache(json& node, std::string const& key, int64_t defValue = 0ll);
120120

121-
std::pair<std::string, int32_t> getRelevantFunctionFromCallStack();
121+
struct FunctionInfo
122+
{
123+
std::string functionName;
124+
int32_t lineNumber = 0;
125+
};
126+
127+
FunctionInfo getRelevantFunctionFromCallStack();
122128

123129
struct GAUtilities
124130
{

source/gameanalytics/GameAnalytics.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -539,13 +539,7 @@ namespace gameanalytics
539539

540540
const std::string message = utilities::trimString(message_, maxErrMsgSize);
541541

542-
std::string function;
543-
int32_t line = -1;
544-
545-
std::pair<std::string, int32_t> inFunction = utilities::getRelevantFunctionFromCallStack();
546-
547-
function = inFunction.first;
548-
line = inFunction.second;
542+
utilities::FunctionInfo finfo = utilities::getRelevantFunctionFromCallStack();
549543

550544
if(fields.size() > maxFieldsSize)
551545
{
@@ -563,7 +557,7 @@ namespace gameanalytics
563557
try
564558
{
565559
json fieldsJson = utilities::parseFields(fields);
566-
events::GAEvents::addErrorEvent(severity, message, function, line, fieldsJson, mergeFields);
560+
events::GAEvents::addErrorEvent(severity, message, finfo.functionName, finfo.lineNumber, fieldsJson, mergeFields);
567561
}
568562
catch(std::exception& e)
569563
{

0 commit comments

Comments
 (0)