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:27:29 UTC

svn commit: r1569091 - in /incubator/log4cxx/trunk/src/main: cpp/propertyconfigurator.cpp include/log4cxx/propertyconfigurator.h

Author: joseph
Date: Mon Feb 17 19:27:29 2014
New Revision: 1569091

URL: http://svn.apache.org/r1569091
Log:
LOGCXX-342

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

Modified: incubator/log4cxx/trunk/src/main/cpp/propertyconfigurator.cpp
URL: http://svn.apache.org/viewvc/incubator/log4cxx/trunk/src/main/cpp/propertyconfigurator.cpp?rev=1569091&r1=1569090&r2=1569091&view=diff
==============================================================================
--- incubator/log4cxx/trunk/src/main/cpp/propertyconfigurator.cpp (original)
+++ incubator/log4cxx/trunk/src/main/cpp/propertyconfigurator.cpp Mon Feb 17 19:27:29 2014
@@ -51,31 +51,34 @@ using namespace log4cxx::config;
 
 #if APR_HAS_THREADS
 #include <log4cxx/helpers/filewatchdog.h>
-
-class PropertyWatchdog  : public FileWatchdog
+namespace log4cxx 
 {
-public:
-        PropertyWatchdog(const File& filename) : FileWatchdog(filename)
-        {
-        }
+	class PropertyWatchdog  : public FileWatchdog
+	{
+	public:
+			PropertyWatchdog(const File& filename) : FileWatchdog(filename)
+			{
+			}
+
+			/**
+			Call PropertyConfigurator#doConfigure(const String& configFileName,
+			const spi::LoggerRepositoryPtr& hierarchy) with the
+			<code>filename</code> to reconfigure log4cxx.
+			*/
+			void doOnChange()
+			{
+					PropertyConfigurator().doConfigure(file,
+							LogManager::getLoggerRepository());
+			}
+	};
+}
+
+PropertyWatchdog *PropertyConfigurator::pdog = NULL;
 
-        /**
-        Call PropertyConfigurator#doConfigure(const String& configFileName,
-        const spi::LoggerRepositoryPtr& hierarchy) with the
-        <code>filename</code> to reconfigure log4cxx.
-        */
-        void doOnChange()
-        {
-                PropertyConfigurator().doConfigure(file,
-                        LogManager::getLoggerRepository());
-        }
-};
 #endif
 
 IMPLEMENT_LOG4CXX_OBJECT(PropertyConfigurator)
 
-
-
 PropertyConfigurator::PropertyConfigurator()
 : registry(new std::map<LogString, AppenderPtr>()), loggerFactory(new DefaultLoggerFactory())
 {
@@ -137,7 +140,9 @@ void PropertyConfigurator::configureAndW
 void PropertyConfigurator::configureAndWatch(
         const File& configFilename, long delay)
 {
-    PropertyWatchdog * pdog = new PropertyWatchdog(configFilename);
+	if(pdog)
+		delete pdog;
+    pdog = new PropertyWatchdog(configFilename);
     APRInitializer::registerCleanup(pdog);
     pdog->setDelay(delay);
     pdog->start();

Modified: incubator/log4cxx/trunk/src/main/include/log4cxx/propertyconfigurator.h
URL: http://svn.apache.org/viewvc/incubator/log4cxx/trunk/src/main/include/log4cxx/propertyconfigurator.h?rev=1569091&r1=1569090&r2=1569091&view=diff
==============================================================================
--- incubator/log4cxx/trunk/src/main/include/log4cxx/propertyconfigurator.h (original)
+++ incubator/log4cxx/trunk/src/main/include/log4cxx/propertyconfigurator.h Mon Feb 17 19:27:29 2014
@@ -50,6 +50,7 @@ namespace log4cxx
         class LoggerFactory;
     }
 
+	class PropertyWatchdog;
 /**
 Allows the configuration of log4cxx from an external file.  See
 <b>{@link #doConfigure(const File&, log4cxx::spi::LoggerRepositoryPtr&)}</b>
@@ -384,6 +385,7 @@ protected:
 private:
       PropertyConfigurator(const PropertyConfigurator&);
       PropertyConfigurator& operator=(const PropertyConfigurator&);
+	  static PropertyWatchdog *pdog;
    }; // class PropertyConfigurator
 }  // namespace log4cxx