You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-dev@logging.apache.org by ca...@apache.org on 2006/01/21 01:09:12 UTC

svn commit: r370933 - in /logging/log4cxx/trunk: build.xml src/hierarchy.cpp tests/src/hierarchytest.cpp

Author: carnold
Date: Fri Jan 20 16:09:07 2006
New Revision: 370933

URL: http://svn.apache.org/viewcvs?rev=370933&view=rev
Log:
LOGCXX-118: Hierarchy corrupted when parent's requested last

Added:
    logging/log4cxx/trunk/tests/src/hierarchytest.cpp   (with props)
Modified:
    logging/log4cxx/trunk/build.xml
    logging/log4cxx/trunk/src/hierarchy.cpp

Modified: logging/log4cxx/trunk/build.xml
URL: http://svn.apache.org/viewcvs/logging/log4cxx/trunk/build.xml?rev=370933&r1=370932&r2=370933&view=diff
==============================================================================
--- logging/log4cxx/trunk/build.xml (original)
+++ logging/log4cxx/trunk/build.xml Fri Jan 20 16:09:07 2006
@@ -392,17 +392,17 @@
     <echo message="Configuring with logchar_type=${logchar_type}" />
 
     <condition property="logchar_is_utf8" value="1">
-	    <equals arg1="${logchar_type}" arg2="utf-8"/>
+       <equals arg1="${logchar_type}" arg2="utf-8"/>
     </condition>
     <property name="logchar_is_utf8" value="0"/>
 
     <condition property="logchar_is_cfstring" value="1">
-	    <equals arg1="${logchar_type}" arg2="cfstring"/>
+       <equals arg1="${logchar_type}" arg2="cfstring"/>
     </condition>
     <property name="logchar_is_cfstring" value="0"/>
 
     <condition property="logchar_is_wchar" value="1">
-	    <equals arg1="${logchar_type}" arg2="wchar_t"/>
+       <equals arg1="${logchar_type}" arg2="wchar_t"/>
     </condition>
     <property name="logchar_is_wchar" value="0"/>
 

Modified: logging/log4cxx/trunk/src/hierarchy.cpp
URL: http://svn.apache.org/viewcvs/logging/log4cxx/trunk/src/hierarchy.cpp?rev=370933&r1=370932&r2=370933&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/hierarchy.cpp (original)
+++ logging/log4cxx/trunk/src/hierarchy.cpp Fri Jan 20 16:09:07 2006
@@ -297,7 +297,7 @@
                 LogString substr = name.substr(0, i);
                 //tcout << _T("UpdateParents processing ") << substr << std::endl;
 
-                                LoggerMap::iterator it = loggers.find(substr);
+                LoggerMap::iterator it = loggers.find(substr);
                 if(it != loggers.end())
                 {
                         parentFound = true;
@@ -306,7 +306,7 @@
                 }
                 else
                 {
-                        ProvisionNodeMap::iterator it2 = provisionNodes.find(name);
+                        ProvisionNodeMap::iterator it2 = provisionNodes.find(substr);
                         if (it2 != provisionNodes.end())
                         {
                                 it2->second.push_back(logger);

Added: logging/log4cxx/trunk/tests/src/hierarchytest.cpp
URL: http://svn.apache.org/viewcvs/logging/log4cxx/trunk/tests/src/hierarchytest.cpp?rev=370933&view=auto
==============================================================================
--- logging/log4cxx/trunk/tests/src/hierarchytest.cpp (added)
+++ logging/log4cxx/trunk/tests/src/hierarchytest.cpp Fri Jan 20 16:09:07 2006
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+#include <log4cxx/logger.h>
+#include <log4cxx/hierarchy.h>
+#include "insertwide.h"
+
+using namespace log4cxx;
+
+/**
+ * Tests hierarchy.
+ * @author Curt Arnold
+ */
+class HierarchyTest : public CppUnit::TestFixture {
+  CPPUNIT_TEST_SUITE(HierarchyTest);
+          CPPUNIT_TEST(testGetParent);
+  CPPUNIT_TEST_SUITE_END();
+public:
+
+    /**
+     * Tests getParent.
+     */
+  void testGetParent() {
+      //
+      //  Note: test inspired by LOGCXX-118.
+      //
+      LoggerPtr logger1(Logger::getLogger("HierarchyTest_testGetParent.logger1"));
+      CPPUNIT_ASSERT_EQUAL(LogString(LOG4CXX_STR("root")), logger1->getParent()->getName());
+      LoggerPtr logger2(Logger::getLogger("HierarchyTest_testGetParent.logger2"));
+      CPPUNIT_ASSERT_EQUAL(LogString(LOG4CXX_STR("root")), logger1->getParent()->getName());
+      LoggerPtr logger3(Logger::getLogger("HierarchyTest_testGetParent"));
+      CPPUNIT_ASSERT_EQUAL(LogString(LOG4CXX_STR("HierarchyTest_testGetParent")), 
+          logger1->getParent()->getName());
+      CPPUNIT_ASSERT_EQUAL(LogString(LOG4CXX_STR("HierarchyTest_testGetParent")), 
+          logger2->getParent()->getName());
+  }
+
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION(HierarchyTest);
+

Propchange: logging/log4cxx/trunk/tests/src/hierarchytest.cpp
------------------------------------------------------------------------------
    svn:executable = *