You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by sw...@apache.org on 2024/05/01 00:47:50 UTC
(logging-log4cxx) 01/01: Include the number of events AsyncAppender discarded in debug output
This is an automated email from the ASF dual-hosted git repository.
swebb2066 pushed a commit to branch async_discard_count
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git
commit 04338932a1e54e1b5bfda26c18ff1ce2a6a51466
Author: Stephen Webb <sw...@gmail.com>
AuthorDate: Wed May 1 10:47:32 2024 +1000
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 7cc0f9f5..95f5ece2 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<LogString, DiscardSummary> DiscardMap;
@@ -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;
@@ -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(' ');