From 04338932a1e54e1b5bfda26c18ff1ce2a6a51466 Mon Sep 17 00:00:00 2001 From: Stephen Webb Date: Wed, 1 May 2024 10:47:32 +1000 Subject: [PATCH] Include the number of events AsyncAppender discarded in debug output --- src/main/cpp/asyncappender.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/cpp/asyncappender.cpp b/src/main/cpp/asyncappender.cpp index 7cc0f9f59..95f5ece28 100644 --- a/src/main/cpp/asyncappender.cpp +++ b/src/main/cpp/asyncappender.cpp @@ -91,6 +91,11 @@ class DiscardSummary ::LOG4CXX_NS::spi::LoggingEventPtr createEvent(::LOG4CXX_NS::helpers::Pool& p, size_t discardedCount); #endif + + /** + * The number of messages discarded. + */ + int getCount() const { return count; } }; typedef std::map DiscardMap; @@ -499,6 +504,7 @@ DiscardSummary::createEvent(::LOG4CXX_NS::helpers::Pool& p, void AsyncAppender::dispatch() { + size_t discardCount = 0; std::vector pendingCountHistogram(priv->bufferSize, 0); bool isActive = true; @@ -533,6 +539,7 @@ void AsyncAppender::dispatch() for (auto discardItem : priv->discardMap) { events.push_back(discardItem.second.createEvent(p)); + discardCount += discardItem.second.getCount(); } priv->discardMap.clear(); } @@ -562,7 +569,10 @@ void AsyncAppender::dispatch() } if (!isActive) { - LogString msg(LOG4CXX_STR("AsyncAppender pendingCountHistogram")); + LogString msg(LOG4CXX_STR("AsyncAppender")); + msg += LOG4CXX_STR(" discardCount "); + StringHelper::toString(discardCount, p, msg); + msg += LOG4CXX_STR(" pendingCountHistogram"); for (auto item : pendingCountHistogram) { msg += logchar(' ');