[asterisk-scf-commits] asterisk-scf/release/logger.git branch "master" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Fri Sep 30 14:29:41 CDT 2011


branch "master" has been updated
       via  9e2737daf979bf41d41c9d655bcce026c94e2c8f (commit)
      from  dc4bdbc50de42e3c810f6ea31aa6e6e14b7b56b7 (commit)

Summary of changes:
 client/src/LogFormatter.cpp |   80 +++++++++++++++++++++---------------------
 1 files changed, 40 insertions(+), 40 deletions(-)


- Log -----------------------------------------------------------------
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/release/logger.git



More information about the asterisk-scf-commits mailing list