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 jo...@apache.org on 2014/02/17 20:28:19 UTC

svn commit: r1569092 - in /incubator/log4cxx/trunk/src/main: cpp/domconfigurator.cpp include/log4cxx/xml/domconfigurator.h

Author: joseph
Date: Mon Feb 17 19:28:18 2014
New Revision: 1569092

URL: http://svn.apache.org/r1569092
Log:
LOGCXX-390

Modified:
    incubator/log4cxx/trunk/src/main/cpp/domconfigurator.cpp
    incubator/log4cxx/trunk/src/main/include/log4cxx/xml/domconfigurator.h

Modified: incubator/log4cxx/trunk/src/main/cpp/domconfigurator.cpp
URL: http://svn.apache.org/viewvc/incubator/log4cxx/trunk/src/main/cpp/domconfigurator.cpp?rev=1569092&r1=1569091&r2=1569092&view=diff
==============================================================================
--- incubator/log4cxx/trunk/src/main/cpp/domconfigurator.cpp (original)
+++ incubator/log4cxx/trunk/src/main/cpp/domconfigurator.cpp Mon Feb 17 19:28:18 2014
@@ -57,23 +57,30 @@ using namespace log4cxx::rolling;
 
 
 #if APR_HAS_THREADS
-class XMLWatchdog  : public FileWatchdog
+namespace log4cxx
 {
-public:
-        XMLWatchdog(const File& filename) : FileWatchdog(filename)
-        {
-        }
-
-        /**
-        Call DOMConfigurator#doConfigure with the
-        <code>filename</code> to reconfigure log4cxx.
-        */
-        void doOnChange()
-        {
-                DOMConfigurator().doConfigure(file,
-                        LogManager::getLoggerRepository());
-        }
-};
+    namespace xml
+    {
+		class XMLWatchdog  : public FileWatchdog
+		{
+		public:
+			XMLWatchdog(const File& filename) : FileWatchdog(filename)
+			{
+			}
+
+			/**
+			Call DOMConfigurator#doConfigure with the
+			<code>filename</code> to reconfigure log4cxx.
+			*/
+			void doOnChange()
+			{
+				DOMConfigurator().doConfigure(file,
+						LogManager::getLoggerRepository());
+			}
+		};
+	}
+}
+XMLWatchdog *DOMConfigurator::xdog = NULL;
 #endif
 
 
@@ -814,7 +821,8 @@ void DOMConfigurator::configureAndWatch(
 {
         File file(filename);
 #if APR_HAS_THREADS
-        XMLWatchdog * xdog = new XMLWatchdog(file);
+		if( xdog ) delete xdog;
+        xdog = new XMLWatchdog(file);
         APRInitializer::registerCleanup(xdog);
         xdog->setDelay(delay);
         xdog->start();
@@ -828,7 +836,8 @@ void DOMConfigurator::configureAndWatch(
 {
         File file(filename);
 #if APR_HAS_THREADS
-        XMLWatchdog * xdog = new XMLWatchdog(file);
+		if( xdog ) delete xdog;
+        xdog = new XMLWatchdog(file);
         APRInitializer::registerCleanup(xdog);
         xdog->setDelay(delay);
         xdog->start();
@@ -843,7 +852,9 @@ void DOMConfigurator::configureAndWatch(
 {
         File file(filename);
 #if APR_HAS_THREADS
-        XMLWatchdog * xdog = new XMLWatchdog(file);
+		if( xdog ) delete xdog;
+        xdog = new XMLWatchdog(file);
+        APRInitializer::registerCleanup(xdog);
         xdog->setDelay(delay);
         xdog->start();
 #else
@@ -857,7 +868,9 @@ void DOMConfigurator::configureAndWatch(
 {
         File file(filename);
 #if APR_HAS_THREADS
-        XMLWatchdog * xdog = new XMLWatchdog(file);
+		if( xdog ) delete xdog;
+        xdog = new XMLWatchdog(file);
+        APRInitializer::registerCleanup(xdog);
         xdog->setDelay(delay);
         xdog->start();
 #else

Modified: incubator/log4cxx/trunk/src/main/include/log4cxx/xml/domconfigurator.h
URL: http://svn.apache.org/viewvc/incubator/log4cxx/trunk/src/main/include/log4cxx/xml/domconfigurator.h?rev=1569092&r1=1569091&r2=1569092&view=diff
==============================================================================
--- incubator/log4cxx/trunk/src/main/include/log4cxx/xml/domconfigurator.h (original)
+++ incubator/log4cxx/trunk/src/main/include/log4cxx/xml/domconfigurator.h Mon Feb 17 19:28:18 2014
@@ -49,6 +49,7 @@ namespace log4cxx
 
         namespace xml
         {
+			class XMLWatchdog;
 
               /**
               Use this class to initialize the log4cxx environment using a DOM tree.
@@ -303,7 +304,7 @@ namespace log4cxx
                         //   prevent assignment or copy statements
                         DOMConfigurator(const DOMConfigurator&);
                         DOMConfigurator& operator=(const DOMConfigurator&);
-
+						static XMLWatchdog *xdog;
                 };
             LOG4CXX_PTR_DEF(DOMConfigurator);
         }  // namespace xml