[asterisk-scf-commits] asterisk-scf/integration/logger.git branch "no_c++11" created.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Fri Nov 18 18:24:20 CST 2011


branch "no_c++11" has been created
        at  3e8297bcf898a8b5f03188a3fbeebc67df423851 (commit)

- Log -----------------------------------------------------------------
commit 3e8297bcf898a8b5f03188a3fbeebc67df423851
Author: Ken Hunt <ken.hunt at digium.com>
Date:   Fri Nov 18 18:22:06 2011 -0600

    Handle the fact that boost's lexical cast on a boost path puts double quotes on the result as of Boost 1.47.

diff --git a/client/src/LogFormatter.cpp b/client/src/LogFormatter.cpp
index e05e3d6..e4d1329 100644
--- a/client/src/LogFormatter.cpp
+++ b/client/src/LogFormatter.cpp
@@ -62,7 +62,18 @@ string AsteriskSCF::System::Logging::sourceInfoStr(const string& fmt, unsigned i
         if ((pos=s.find("$sf",0))!=string::npos)
         {
             boost::filesystem::path p(file);
-            s.replace(pos,3,boost::lexical_cast<string>(p.leaf()));
+            string fileName = boost::lexical_cast<string>(p.leaf());
+            if (fileName[0] == '\"')
+            {
+                fileName.erase(fileName.begin());
+            }
+
+            if (fileName[fileName.size() - 1] == '\"')
+            {
+                fileName.erase(fileName.end() - 1);
+            }
+
+            s.replace(pos,3,fileName);
             found = true;
         }
     }

commit b9435b7ce538e1c33da69c395491e8c0f9e51324
Author: Ken Hunt <ken.hunt at digium.com>
Date:   Tue Oct 4 12:04:19 2011 -0500

    Fixed potential for null pointer exception.

diff --git a/client/src/IceLogger.cpp b/client/src/IceLogger.cpp
index 87d85ae..ca1a7f7 100644
--- a/client/src/IceLogger.cpp
+++ b/client/src/IceLogger.cpp
@@ -242,10 +242,10 @@ ConfiguredIceLoggerPtr AsteriskSCF::System::Logging::createIceLogger(
             e.what() << '\n';
     }
 
-    // ServiceLocator used AMD, which won't work with collocation optimization
     ServiceLocatorPrx locator = ServiceLocatorPrx::uncheckedCast(
-        communicator->propertyToProxy("LocatorService.Proxy")
-            ->ice_collocationOptimized(false));
+          communicator->stringToProxy(communicator->getProperties()->getPropertyWithDefault(
+          "LocatorService.Proxy", "LocatorService:default -p 4411")));
+
     // if the LocatorService.Proxy isn't set, we'll log a message, but proceed
     // on in ignorance.  we'll basically build an IceLogger that can never
     // log to a LoggerServer because it can never find it.
@@ -254,6 +254,11 @@ ConfiguredIceLoggerPtr AsteriskSCF::System::Logging::createIceLogger(
         std::clog << "(Logger) LocatorService.Proxy not set.  Cannot find "
                   << LoggingServerGuid << '\n';
     }
+    else
+    {
+        // ServiceLocator uses AMD, which won't work with collocation optimization
+        locator->ice_collocationOptimized(false);
+    }
 
     ConfiguredIceLoggerPtr logger = ConfiguredIceLogger::create(locator, serviceName);
     Ice::ObjectPrx proxy = adapter->addWithUUID(logger);

commit 9e2737daf979bf41d41c9d655bcce026c94e2c8f
Author: Ken Hunt <ken.hunt at digium.com>
Date:   Fri Sep 30 14:29:07 2011 -0500

    Incorporated overlooked review feedback.

diff --git a/client/src/LogFormatter.cpp b/client/src/LogFormatter.cpp
index f747772..e05e3d6 100644
--- a/client/src/LogFormatter.cpp
+++ b/client/src/LogFormatter.cpp
@@ -22,7 +22,7 @@
 using namespace AsteriskSCF::System::Logging;
 using namespace std;
 
-LogFormatter::LogFormatter(const std::string& fmtStr) :
+LogFormatter::LogFormatter(const string& fmtStr) :
     mFormat(fmtStr)
 {
 }
@@ -34,60 +34,60 @@ LogFormatter::~LogFormatter()
 /**
  * Builds a formatted string with some source code information in it.
  */
-std::string AsteriskSCF::System::Logging::sourceInfoStr(const std::string& fmt, unsigned int line,
+string AsteriskSCF::System::Logging::sourceInfoStr(const string& fmt, unsigned int line,
                                                         const char* fcn, const char* file)
 {
-    std::string s(fmt);
-    std::size_t pos;
+    string s(fmt);
+    size_t pos;
     bool found = true;
     
     while (found)
     {
         found = false;
-        if ((pos=s.find("$l",0))!=std::string::npos)
+        if ((pos=s.find("$l",0))!=string::npos)
         {
-            s.replace(pos,2,boost::lexical_cast<std::string>(line));
+            s.replace(pos,2,boost::lexical_cast<string>(line));
             found = true;
         }
-        if ((pos=s.find("$f",0))!=std::string::npos)
+        if ((pos=s.find("$f",0))!=string::npos)
         {
-            s.replace(pos,2,boost::lexical_cast<std::string>(fcn));
+            s.replace(pos,2,boost::lexical_cast<string>(fcn));
             found = true;
         }
-        if ((pos=s.find("$sp",0))!=std::string::npos)
+        if ((pos=s.find("$sp",0))!=string::npos)
         {
-            s.replace(pos,3,boost::lexical_cast<std::string>(file));
+            s.replace(pos,3,boost::lexical_cast<string>(file));
             found = true;
         }
-        if ((pos=s.find("$sf",0))!=std::string::npos)
+        if ((pos=s.find("$sf",0))!=string::npos)
         {
             boost::filesystem::path p(file);
-            s.replace(pos,3,boost::lexical_cast<std::string>(p.leaf()));
+            s.replace(pos,3,boost::lexical_cast<string>(p.leaf()));
             found = true;
         }
     }
     return s;
 }
 
-void LogFormatter::setFormat(const std::string& fmtStr)
+void LogFormatter::setFormat(const string& fmtStr)
 {
     boost::unique_lock<boost::shared_mutex> lock(mMutex);
     mFormat = fmtStr;
 }
 
-std::string LogFormatter::getFormat()
+string LogFormatter::getFormat()
 {
     boost::shared_lock<boost::shared_mutex> lock(mMutex);
 
     return mFormat;
 }
 
-std::string getFormattedTime(const boost::posix_time::ptime& t, const std::string& format)
+string getFormattedTime(const boost::posix_time::ptime& t, const string& format)
 {
     boost::posix_time::time_facet* outputFacet = new boost::posix_time::time_facet();
 
-    std::stringstream ss;
-    ss.imbue(std::locale(std::locale::classic(), outputFacet));
+    stringstream ss;
+    ss.imbue(locale(locale::classic(), outputFacet));
     outputFacet->format(format.c_str());
 
     ss << t;
@@ -95,9 +95,9 @@ std::string getFormattedTime(const boost::posix_time::ptime& t, const std::strin
     return ss.str();
 }
 
-std::string getFormattedTime(const  boost::posix_time::ptime& t)
+string getFormattedTime(const  boost::posix_time::ptime& t)
 {
-    std::stringstream ss;
+    stringstream ss;
 
     ss << t;
     return ss.str();
@@ -106,26 +106,26 @@ std::string getFormattedTime(const  boost::posix_time::ptime& t)
 /**
  * Formats a log string and returns it for output
  */
-std::string LogFormatter::formatMessage(const std::string& message, const std::string& name, Level level,
-        const std::string& hostName, Ice::Long pid, 
-        const std::string& componentCategory, const std::string& serviceId, const std::string& instanceId) const
+string LogFormatter::formatMessage(const string& message, const string& name, Level level,
+        const string& hostName, Ice::Long pid, 
+        const string& componentCategory, const string& serviceId, const string& instanceId) const
 {
-    std::string outStr;
-    std::size_t pos;
+    string outStr;
+    size_t pos;
     outStr = mFormat;
 
-    if ((pos=outStr.find("$t{",0)) != std::string::npos)
+    if ((pos=outStr.find("$t{",0)) != string::npos)
     {
         // Client timestamp (formatted). 
         try
         {
             boost::posix_time::ptime now(boost::posix_time::microsec_clock::universal_time());
 
-            std::size_t pos2 = outStr.find("}",pos+3);
-            if (pos2 != std::string::npos)
+            size_t pos2 = outStr.find("}",pos+3);
+            if (pos2 != string::npos)
             {
-                std::string userTimeFormat = outStr.substr(pos+3,pos2-3);
-                std::string nowStr = getFormattedTime(now, userTimeFormat);
+                string userTimeFormat = outStr.substr(pos+3,pos2-3);
+                string nowStr = getFormattedTime(now, userTimeFormat);
 
                 outStr.replace(pos,pos+pos2+1,nowStr);
             }
@@ -136,7 +136,7 @@ std::string LogFormatter::formatMessage(const std::string& message, const std::s
            // in the output and signal to someone that the format is wrong
         }
     }
-    else if ((pos=outStr.find("$t",0)) != std::string::npos)
+    else if ((pos=outStr.find("$t",0)) != string::npos)
     {
         // Client timestamp (default formatting)
         boost::posix_time::ptime now(boost::posix_time::microsec_clock::universal_time());
@@ -145,22 +145,22 @@ std::string LogFormatter::formatMessage(const std::string& message, const std::s
         outStr.replace(pos,2,nowString);
     }
 
-    if ((pos=outStr.find("$n",0)) != std::string::npos)
+    if ((pos=outStr.find("$n",0)) != string::npos)
     {
         // Logger name
         outStr.replace(pos,2,name);
     }
 
-    if ((pos=outStr.find("$l",0)) != std::string::npos)
+    if ((pos=outStr.find("$l",0)) != string::npos)
     {
         // Priority / level
-        std::stringstream s("");
+        stringstream s("");
 
         s << level;
         outStr.replace(pos,2,s.str());
     }
 
-    if ((pos=outStr.find("$h",0)) != std::string::npos)
+    if ((pos=outStr.find("$h",0)) != string::npos)
     {
         // Client host name
         if (hostName.size()==0)
@@ -170,28 +170,28 @@ std::string LogFormatter::formatMessage(const std::string& message, const std::s
         else outStr.replace(pos,2,hostName);
     }
 
-    if ((pos=outStr.find("$p",0)) != std::string::npos)
+    if ((pos=outStr.find("$p",0)) != string::npos)
     {
         // Process ID
-        outStr.replace(pos,2,boost::lexical_cast<std::string>(pid));
+        outStr.replace(pos,2,boost::lexical_cast<string>(pid));
     }
 
-    if ((pos=outStr.find("$C",0)) != std::string::npos)
+    if ((pos=outStr.find("$C",0)) != string::npos)
     {
         outStr.replace(pos, 2, componentCategory);
     }
 
-    if ((pos=outStr.find("$S",0)) != std::string::npos)
+    if ((pos=outStr.find("$S",0)) != string::npos)
     {
          outStr.replace(pos, 2, serviceId);
     }
 
-    if ((pos=outStr.find("$I",0)) != std::string::npos)
+    if ((pos=outStr.find("$I",0)) != string::npos)
     {
          outStr.replace(pos, 2, instanceId);
     }
 
-    if ((pos=outStr.find("$m",0)) != std::string::npos)
+    if ((pos=outStr.find("$m",0)) != string::npos)
     {
         // Check for message specifier last so we don't modify the message itself
         outStr.replace(pos,2,message);

-----------------------------------------------------------------------


-- 
asterisk-scf/integration/logger.git



More information about the asterisk-scf-commits mailing list