From 685a44ed53fcba80c5ecea593cc71de571437f1c Mon Sep 17 00:00:00 2001 From: James Turner Date: Tue, 3 Nov 2020 17:58:32 +0000 Subject: [PATCH] Sentry: combine repeated log messages Should make the breadcrumbs easier to read. --- src/Main/sentryIntegration.cxx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Main/sentryIntegration.cxx b/src/Main/sentryIntegration.cxx index ab7d916a9..44313d79c 100644 --- a/src/Main/sentryIntegration.cxx +++ b/src/Main/sentryIntegration.cxx @@ -133,9 +133,24 @@ public: return true; } + if (e.message == _lastLoggedMessage) { + _lastLoggedCount++; + return true; + } + + if (_lastLoggedCount > 0) { + flightgear::addSentryBreadcrumb("(repeats " + std::to_string(_lastLoggedCount) + " times)", "info"); + _lastLoggedCount = 0; + } + + _lastLoggedMessage = e.message; flightgear::addSentryBreadcrumb(e.message, (op == SG_WARN) ? "warning" : "error"); return true; } + +private: + std::string _lastLoggedMessage; + int _lastLoggedCount = 0; }; } // namespace