Skip to content

Commit

Permalink
Include the number of events AsyncAppender discarded in debug output
Browse files Browse the repository at this point in the history
  • Loading branch information
stephen-webb committed May 1, 2024
1 parent 4f605de commit 0433893
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/main/cpp/asyncappender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<LogString, DiscardSummary> DiscardMap;
Expand Down Expand Up @@ -499,6 +504,7 @@ DiscardSummary::createEvent(::LOG4CXX_NS::helpers::Pool& p,

void AsyncAppender::dispatch()
{
size_t discardCount = 0;
std::vector<size_t> pendingCountHistogram(priv->bufferSize, 0);
bool isActive = true;

Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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(' ');
Expand Down

0 comments on commit 0433893

Please sign in to comment.