Skip to content

Commit 9d4c003

Browse files
committed
put limit on log lines app keeps for Sentry
1 parent fec1d7c commit 9d4c003

File tree

3 files changed

+29
-19
lines changed

3 files changed

+29
-19
lines changed

obs-studio-server/source/nodeobs_api.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2082,17 +2082,17 @@ double OBS_API::getMemoryUsage()
20822082
return (double)os_get_proc_resident_size() / (1024.0 * 1024.0);
20832083
}
20842084

2085-
const std::vector<std::string> &OBS_API::getOBSLogErrors()
2085+
std::deque<std::string> &OBS_API::getOBSLogErrors()
20862086
{
20872087
return logReport.errors;
20882088
}
20892089

2090-
const std::vector<std::string> &OBS_API::getOBSLogWarnings()
2090+
std::deque<std::string> &OBS_API::getOBSLogWarnings()
20912091
{
20922092
return logReport.warnings;
20932093
}
20942094

2095-
std::queue<std::string> &OBS_API::getOBSLogGeneral()
2095+
std::deque<std::string> &OBS_API::getOBSLogGeneral()
20962096
{
20972097
return logReport.general;
20982098
}

obs-studio-server/source/nodeobs_api.h

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include <string.h>
2929
#include <string>
3030
#include <vector>
31-
#include <queue>
31+
#include <deque>
3232
#include "nodeobs_configManager.hpp"
3333
#include "nodeobs_service.h"
3434
#include "util-osx.hpp"
@@ -44,27 +44,33 @@ class OBS_API {
4444

4545
public:
4646
struct LogReport {
47-
static const int MaximumGeneralMessages = 150;
47+
static const int MaximumMessages = 150;
4848

4949
void push(std::string message, int logLevel)
5050
{
51-
general.push(message);
52-
if (general.size() >= MaximumGeneralMessages) {
53-
general.pop();
51+
general.push_back(message);
52+
if (general.size() > MaximumMessages) {
53+
general.pop_front();
5454
}
5555

5656
if (logLevel == LOG_ERROR) {
5757
errors.push_back(message);
58+
if (errors.size() > MaximumMessages) {
59+
errors.pop_front();
60+
}
5861
}
5962

6063
if (logLevel == LOG_WARNING) {
6164
warnings.push_back(message);
65+
if (warnings.size() > MaximumMessages) {
66+
warnings.pop_front();
67+
}
6268
}
6369
}
6470

65-
std::vector<std::string> errors;
66-
std::vector<std::string> warnings;
67-
std::queue<std::string> general;
71+
std::deque<std::string> errors;
72+
std::deque<std::string> warnings;
73+
std::deque<std::string> general;
6874
};
6975

7076
struct OutputStats {
@@ -130,9 +136,9 @@ class OBS_API {
130136
static double getMemoryUsage();
131137
static void getCurrentOutputStats(obs_output_t *output, OBS_API::OutputStats &outputStats);
132138

133-
static const std::vector<std::string> &getOBSLogErrors();
134-
static const std::vector<std::string> &getOBSLogWarnings();
135-
static std::queue<std::string> &getOBSLogGeneral();
139+
static std::deque<std::string> &getOBSLogErrors();
140+
static std::deque<std::string> &getOBSLogWarnings();
141+
static std::deque<std::string> &getOBSLogGeneral();
136142

137143
static std::string getCurrentVersion();
138144
static std::string getUsername();

obs-studio-server/source/util-crashmanager.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,23 +1011,27 @@ nlohmann::json util::CrashManager::RequestOBSLog(OBSLogType type)
10111011
switch (type) {
10121012
case OBSLogType::Errors: {
10131013
auto &errors = OBS_API::getOBSLogErrors();
1014-
for (auto &msg : errors)
1015-
result.push_back(msg);
1014+
while (!errors.empty()) {
1015+
result.push_back(errors.front());
1016+
errors.pop_front();
1017+
}
10161018
break;
10171019
}
10181020

10191021
case OBSLogType::Warnings: {
10201022
auto &warnings = OBS_API::getOBSLogWarnings();
1021-
for (auto &msg : warnings)
1022-
result.push_back(msg);
1023+
while (!warnings.empty()) {
1024+
result.push_back(warnings.front());
1025+
warnings.pop_front();
1026+
}
10231027
break;
10241028
}
10251029

10261030
case OBSLogType::General: {
10271031
auto &general = OBS_API::getOBSLogGeneral();
10281032
while (!general.empty()) {
10291033
result.push_back(general.front());
1030-
general.pop();
1034+
general.pop_front();
10311035
}
10321036

10331037
break;

0 commit comments

Comments
 (0)