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 2008/01/29 10:51:36 UTC

svn commit: r616227 - in /logging/log4cxx/trunk/src/main/cpp: defaultconfigurator.cpp file.cpp

Author: carnold
Date: Tue Jan 29 01:51:34 2008
New Revision: 616227

URL: http://svn.apache.org/viewvc?rev=616227&view=rev
Log:
LOGCXX-226: Default configurator uses *.properties in preference to *.xml

Modified:
    logging/log4cxx/trunk/src/main/cpp/defaultconfigurator.cpp
    logging/log4cxx/trunk/src/main/cpp/file.cpp

Modified: logging/log4cxx/trunk/src/main/cpp/defaultconfigurator.cpp
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/cpp/defaultconfigurator.cpp?rev=616227&r1=616226&r2=616227&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/main/cpp/defaultconfigurator.cpp (original)
+++ logging/log4cxx/trunk/src/main/cpp/defaultconfigurator.cpp Tue Jan 29 01:51:34 2008
@@ -29,36 +29,29 @@
 
 void DefaultConfigurator::configure(LoggerRepository* repository)
 {
-   repository->setConfigured(true);
+        repository->setConfigured(true);
         const LogString configuratorClassName(getConfiguratorClass());
 
         LogString configurationOptionStr(getConfigurationFileName());
         File configuration;
-        configuration.setName(configurationOptionStr);
 
+        Pool pool;
         if (configurationOptionStr.empty())
         {
-                Pool pool;
-                configuration = LOG4CXX_FILE("log4cxx.properties");
+                configuration.setName(LOG4CXX_STR("log4cxx.xml"));
                 if (!configuration.exists(pool)) {
-                    File tmp = LOG4CXX_FILE("log4cxx.xml");
-                    if (tmp.exists(pool)) {
-                        configuration = tmp;
-                    } else {
-                        tmp = LOG4CXX_FILE("log4j.properties");
-                        if (tmp.exists(pool)) {
-                        configuration = tmp;
-                        } else {
-                        tmp = LOG4CXX_FILE("log4j.xml");
-                        if (tmp.exists(pool)) {
-                            configuration = tmp;
-                        }
+                    configuration.setName(LOG4CXX_STR("log4cxx.properties"));
+                    if (!configuration.exists(pool)) {
+                        configuration.setName(LOG4CXX_STR("log4j.xml"));
+                        if (!configuration.exists(pool)) {
+                            configuration.setName(LOG4CXX_STR("log4j.properties"));
                         }
                     }
-                    }
+                }
+        } else {
+            configuration.setName(configurationOptionStr);
         }
 
-        Pool pool;
         if (configuration.exists(pool))
         {
                 LogString msg(LOG4CXX_STR("Using configuration file ["));
@@ -74,9 +67,14 @@
         }
         else
         {
-                LogString msg(LOG4CXX_STR("Could not find configuration file: ["));
-                msg += configuration.getName();
-                msg += LOG4CXX_STR("].");
+                if (configurationOptionStr.empty()) {
+                    LogLog::debug(LOG4CXX_STR("Could not find default configuration file."));
+                } else {
+                    LogString msg(LOG4CXX_STR("Could not find configuration file: ["));
+                    msg += configurationOptionStr;
+                    msg += LOG4CXX_STR("].");
+                    LogLog::debug(msg);
+                }
         }
 
 }

Modified: logging/log4cxx/trunk/src/main/cpp/file.cpp
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/cpp/file.cpp?rev=616227&r1=616226&r2=616227&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/main/cpp/file.cpp (original)
+++ logging/log4cxx/trunk/src/main/cpp/file.cpp Tue Jan 29 01:51:34 2008
@@ -84,6 +84,7 @@
 
 File& File::setName(const LogString& newName) {
     name.assign(newName);
+    osName.clear();
     Transcoder::encode(newName, osName);
     return *this;
 }