You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rm...@apache.org on 2023/07/28 13:44:01 UTC
[logging-log4cxx] branch master updated: Add a way to remove the HierarchyEventListener (#234)
This is an automated email from the ASF dual-hosted git repository.
rmiddleton pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git
The following commit(s) were added to refs/heads/master by this push:
new de4bc7d7 Add a way to remove the HierarchyEventListener (#234)
de4bc7d7 is described below
commit de4bc7d7493ea15d22ccad15d4e74a9c5da298c1
Author: Robert Middleton <rm...@users.noreply.github.com>
AuthorDate: Fri Jul 28 09:43:54 2023 -0400
Add a way to remove the HierarchyEventListener (#234)
* Add a way to remove the HierarchyEventListener
See #233
---
src/main/cpp/hierarchy.cpp | 10 ++++++++++
src/main/include/log4cxx/hierarchy.h | 7 +++++++
2 files changed, 17 insertions(+)
diff --git a/src/main/cpp/hierarchy.cpp b/src/main/cpp/hierarchy.cpp
index e9a63016..23f35289 100644
--- a/src/main/cpp/hierarchy.cpp
+++ b/src/main/cpp/hierarchy.cpp
@@ -111,6 +111,16 @@ void Hierarchy::addHierarchyEventListener(const spi::HierarchyEventListenerPtr&
}
}
+void Hierarchy::removeHierarchyEventListener(const spi::HierarchyEventListenerPtr& listener)
+{
+ std::unique_lock<std::mutex> lock(m_priv->mutex);
+
+ auto found = std::find(m_priv->listeners.begin(), m_priv->listeners.end(), listener);
+ if(found != m_priv->listeners.end()){
+ m_priv->listeners.erase(found);
+ }
+}
+
void Hierarchy::clear()
{
std::unique_lock<std::mutex> lock(m_priv->mutex);
diff --git a/src/main/include/log4cxx/hierarchy.h b/src/main/include/log4cxx/hierarchy.h
index 1173a14f..4bb7400b 100644
--- a/src/main/include/log4cxx/hierarchy.h
+++ b/src/main/include/log4cxx/hierarchy.h
@@ -76,6 +76,13 @@ class LOG4CXX_EXPORT Hierarchy : public spi::LoggerRepository
void addHierarchyEventListener(const spi::HierarchyEventListenerPtr& listener) override;
+ /**
+ * Remove a previously added HierarchyEventListener.
+ *
+ * ABI TODO: Make virtual and add to LoggerRepository.
+ */
+ void removeHierarchyEventListener(const spi::HierarchyEventListenerPtr& listener);
+
/**
* Call \c configurator if not yet configured.
*/