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/04/18 07:10:47 UTC
(logging-log4cxx) 01/01: Prevent fault when using one of the LevelChange constructors
This is an automated email from the ASF dual-hosted git repository.
swebb2066 pushed a commit to branch level_change_bug
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git
commit 67f3d0b4bccb30edcfa9e92dd538619b0e2a5326
Author: Stephen Webb <sw...@gmail.com>
AuthorDate: Thu Apr 18 17:10:24 2024 +1000
Prevent fault when using one of the LevelChange constructors
---
src/main/include/log4cxx/levelchange.h | 2 +-
src/test/cpp/levelchangetestcase.cpp | 8 +++++++-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/main/include/log4cxx/levelchange.h b/src/main/include/log4cxx/levelchange.h
index df2f6f96..1a5ec573 100644
--- a/src/main/include/log4cxx/levelchange.h
+++ b/src/main/include/log4cxx/levelchange.h
@@ -52,7 +52,7 @@ public: // ...structors
}
/// Set \c otherCategory to the level of \c thisCategory
LevelChange(const LoggerPtr& otherCategory, const LoggerPtr& thisCategory)
- : LevelChange(otherCategory, m_otherCategory->getLevel())
+ : LevelChange(otherCategory, thisCategory->getLevel())
{
}
/// Set the logger named \c otherCategory to \c level
diff --git a/src/test/cpp/levelchangetestcase.cpp b/src/test/cpp/levelchangetestcase.cpp
index 85ea1eb2..6a6175d1 100644
--- a/src/test/cpp/levelchangetestcase.cpp
+++ b/src/test/cpp/levelchangetestcase.cpp
@@ -124,11 +124,17 @@ public:
processor.DoStep1();
LOGUNIT_ASSERT_EQUAL(appender->count, initialCount);
{
- LevelChange x(LOG4CXX_STR("ComplexProcessing"), myLogger);
+ LevelChange ctx(getLogger(LOG4CXX_STR("ComplexProcessing")), myLogger);
processor.DoStep2();
// Check the ComplexProcessing debug request was sent to the appender
LOGUNIT_ASSERT_EQUAL(appender->count, initialCount + 1);
}
+ {
+ LevelChange ctx(LOG4CXX_STR("ComplexProcessing"), myLogger);
+ processor.DoStep2();
+ // Check the ComplexProcessing debug request was sent to the appender
+ LOGUNIT_ASSERT_EQUAL(appender->count, initialCount + 2);
+ }
// Check the ComplexProcessing debug request is no longer sent to the appender
auto finalCount = appender->count;