Skip to content

Commit

Permalink
UI: Fix repeated log entries
Browse files Browse the repository at this point in the history
  • Loading branch information
exeldro committed Jan 13, 2025
1 parent a0e4e37 commit 7c36455
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions UI/obs-app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,11 @@ static inline bool too_many_repeated_entries(fstream &logFile, const char *msg,
static mutex log_mutex;
static const char *last_msg_ptr = nullptr;
static int last_char_sum = 0;
static size_t last_len = 0;
static int rep_count = 0;

int new_sum = sum_chars(output_str);
size_t new_len = strlen(output_str);

lock_guard<mutex> guard(log_mutex);

Expand All @@ -357,6 +359,8 @@ static inline bool too_many_repeated_entries(fstream &logFile, const char *msg,
if (diff < MAX_CHAR_VARIATION) {
return (rep_count++ >= MAX_REPEATED_LINES);
}
} else if (last_len == new_len && new_sum == last_char_sum) {
return (rep_count++ >= MAX_REPEATED_LINES);
}

if (rep_count > MAX_REPEATED_LINES) {
Expand All @@ -366,6 +370,7 @@ static inline bool too_many_repeated_entries(fstream &logFile, const char *msg,

last_msg_ptr = msg;
last_char_sum = new_sum;
last_len = new_len;
rep_count = 0;

return false;
Expand Down

0 comments on commit 7c36455

Please sign in to comment.