[asterisk-scf-commits] asterisk-scf/integration/logger.git branch "retry_deux" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Fri Mar 9 11:17:32 CST 2012


branch "retry_deux" has been updated
       via  45916eeb263c022fade37c44376afcf29bbe72e3 (commit)
       via  8e2926240116cb660ce80b7d129fb84bd20f781e (commit)
       via  fb00b2fd21f879b34dd658c9cd62e77dc12be184 (commit)
       via  14a58d5619810a239e5efe35052a5d558fd6576e (commit)
       via  5a430c1eeccead2e308d276f39c09b58072a8cbf (commit)
      from  1503c024f77521c2bda47c903ca2ee66e360fc96 (commit)

Summary of changes:
 client/src/LogFormatter.cpp          |   29 +++++++++++++++++++++++++----
 client/test/ExpectedLogOut.h         |   11 ++++++-----
 client/test/IceConfigurator-test.cpp |    4 +++-
 client/test/Logger-test.cpp          |   14 +++++++++-----
 server/src/LoggingServer.cpp         |    4 +++-
 5 files changed, 46 insertions(+), 16 deletions(-)


- Log -----------------------------------------------------------------
commit 45916eeb263c022fade37c44376afcf29bbe72e3
Merge: 1503c02 8e29262
Author: David M. Lee <dlee at digium.com>
Date:   Thu Mar 8 17:18:23 2012 -0600

    Merge branch 'master' into retry_deux


commit 8e2926240116cb660ce80b7d129fb84bd20f781e
Author: David M. Lee <dlee at digium.com>
Date:   Thu Mar 8 17:02:19 2012 -0600

    Fix for Windows + newer Boost.
    
    Turns out that .native() on Windows returns a wstring instead of a narrow
    string. Using the .string() function works much better (go figure).

diff --git a/client/src/LogFormatter.cpp b/client/src/LogFormatter.cpp
index a45112e..126af87 100644
--- a/client/src/LogFormatter.cpp
+++ b/client/src/LogFormatter.cpp
@@ -79,7 +79,7 @@ string AsteriskSCF::System::Logging::sourceInfoStr(const string& fmt, unsigned i
 	    // the #if, but it would sometimes quote the filename, which is
 	    // uncool.
 #if BOOST_FILESYSTEM_VERSION >= 3
-            basename = p.filename().native();
+            basename = p.filename().string();
 #else
 	    basename = p.filename();
 #endif

commit fb00b2fd21f879b34dd658c9cd62e77dc12be184
Author: David M. Lee <dlee at digium.com>
Date:   Mon Feb 13 08:43:54 2012 -0600

    Adding support for older versions of Boost

diff --git a/client/src/LogFormatter.cpp b/client/src/LogFormatter.cpp
index dd0362f..a45112e 100644
--- a/client/src/LogFormatter.cpp
+++ b/client/src/LogFormatter.cpp
@@ -62,7 +62,28 @@ 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,p.filename().native());
+	    std::string basename;
+	    // According to http://www.boost.org/doc/libs/1_48_0/libs/filesystem/v2/doc/index.htm:
+	    //
+	    // Boost 1.44 introduced Filesystem Library v3, with breaking API
+	    // changes.
+	    //
+	    // Boost 1.44 through 1.47 included both v2 and v3 API's.
+	    //
+	    // The default API was changed to v3 in 1.46.
+	    //
+	    // As such, code to support Boost 1.40 and the latest Boost is
+	    // sadly complicated.
+	    //
+	    // This code originally tried to use boost::lexical_cast to avoid
+	    // the #if, but it would sometimes quote the filename, which is
+	    // uncool.
+#if BOOST_FILESYSTEM_VERSION >= 3
+            basename = p.filename().native();
+#else
+	    basename = p.filename();
+#endif
+            s.replace(pos,3,basename);
             found = true;
         }
     }

commit 14a58d5619810a239e5efe35052a5d558fd6576e
Author: David M. Lee <dlee at digium.com>
Date:   Fri Feb 10 13:11:10 2012 -0600

    Several logger unit test fixes.
    
    * Lexically casting a path to string inconsistently put double quotes around
      the path. Use .native() instead
    * Client side time formatting was simply broken.
    * Rewrote ExpectedLogOut.check so the assertion message was actually useful.
    * Added note about the brittleness of the time sensitive tests.

diff --git a/client/src/LogFormatter.cpp b/client/src/LogFormatter.cpp
index 45787d3..dd0362f 100644
--- a/client/src/LogFormatter.cpp
+++ b/client/src/LogFormatter.cpp
@@ -62,7 +62,7 @@ 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()));
+            s.replace(pos,3,p.filename().native());
             found = true;
         }
     }
@@ -121,13 +121,13 @@ string LogFormatter::formatMessage(const string& message, const string& name, Le
         {
             boost::posix_time::ptime now(boost::posix_time::microsec_clock::universal_time());
 
-            size_t pos2 = outStr.find("}",pos+3);
+            size_t pos2 = outStr.find("}",pos + 3);
             if (pos2 != string::npos)
             {
-                string userTimeFormat = outStr.substr(pos+3,pos2-3);
+                string userTimeFormat = outStr.substr(pos + 3, pos2 - pos - 3);
                 string nowStr = getFormattedTime(now, userTimeFormat);
 
-                outStr.replace(pos,pos+pos2+1,nowStr);
+                outStr.replace(pos, pos2 - pos + 1, nowStr);
             }
         }
         catch (...)
diff --git a/client/test/ExpectedLogOut.h b/client/test/ExpectedLogOut.h
index 9ef96ac..0b8c702 100644
--- a/client/test/ExpectedLogOut.h
+++ b/client/test/ExpectedLogOut.h
@@ -32,18 +32,19 @@ public:
 
     void check()
     {
-        std::string actual = mActual.str();
-        BOOST_CHECK(0 == actual.compare(0, mExpected.length(), mExpected));
+        check(0);
     }
 
-    /** 
-     * @param less Shorten the length to compare by this amount. 
+    /**
+     * @param less Shorten the length to compare by this amount.
      * (Time strings won't match the last few digits.)
      */
     void check(int less)
     {
         std::string actual = mActual.str();
-        BOOST_CHECK(0 == actual.compare(0, (mExpected.length() - less), mExpected, 0, (mExpected.length() - less)));
+        BOOST_CHECK_EQUAL(
+            mExpected.substr(0, mExpected.size() - less),
+            actual.substr(0, actual.size() - less));
     }
 
     boost::shared_ptr<LogOut> operator()() 
diff --git a/client/test/Logger-test.cpp b/client/test/Logger-test.cpp
index 8200440..96d6f19 100644
--- a/client/test/Logger-test.cpp
+++ b/client/test/Logger-test.cpp
@@ -116,7 +116,7 @@ BOOST_AUTO_TEST_CASE(test_stream_format)
 
     std::string hostName = boost::asio::ip::host_name();
 
-    BOOST_REQUIRE(hostName.length() != 0); 
+    BOOST_REQUIRE(hostName.length() != 0);
     ExpectedLogOut out("Debug:src:" + hostName + ": debug f00d\n",
                        "$l:$n:$h: $m");
 
@@ -155,12 +155,16 @@ BOOST_AUTO_TEST_CASE(test_stream_timestamp)
     Ice::Long pid = (Ice::Long)boost::interprocess::ipcdetail::get_current_process_id();
     std::string nowStr = getFormattedTime(now);
 
-    ExpectedLogOut out(boost::lexical_cast<std::string>(pid) + ":src:Debug:TimeStamp test:Logger-test.cpp : " + nowStr,
+    ExpectedLogOut out(boost::lexical_cast<std::string>(pid) + ":src:Debug:TimeStamp test:Logger-test.cpp : " + nowStr + "\n",
         "$p:$n:$l:$m : $t");
     Logger uut("src", *out(), Debug);
 
     uut(Debug) << "TimeStamp test:" << SRCINFO("$sf") << '\n';
 
+    // TODO - This test is brittle b/c it assumes that time may only change in the least significant
+    // digits. But it's possible this test runs just as the second rolls over, causing this test to
+    // fail. Instead, the TimeFormatter should be provided with a TimeFactory test double that
+    // provides a stable value for the current time.
     out.check(6);
 }
 
@@ -170,12 +174,12 @@ BOOST_AUTO_TEST_CASE(test_stream_timestamp_formatted)
 
     std::string nowStr = getFormattedTime(now, "%x %H:%M:%S%p");
 
-    ExpectedLogOut out("src:Debug:TimeStamp format test " + nowStr,
-                       "$n:$l:$m $t{%x %H:%M:%S%p}");
+    ExpectedLogOut out("src:Debug:TimeStamp format test (" + nowStr + ")\n",
+                       "$n:$l:$m ($t{%x %H:%M:%S%p})");
     Logger uut("src", *out(), Debug);
 
     uut(Debug) << "TimeStamp format test" << '\n';
-    out.check(6);
+    out.check();
 }
 
 

commit 5a430c1eeccead2e308d276f39c09b58072a8cbf
Author: Brent Eagles <beagles at digium.com>
Date:   Thu Feb 9 15:23:53 2012 -0330

    Fix build error on Windows.

diff --git a/client/test/IceConfigurator-test.cpp b/client/test/IceConfigurator-test.cpp
index 5b6988a..51b3e56 100644
--- a/client/test/IceConfigurator-test.cpp
+++ b/client/test/IceConfigurator-test.cpp
@@ -26,7 +26,9 @@ namespace
 {
 void addConfig(Configuration& cfg, const std::string& name, Level logLevel)
 {
-    SourceConfiguration sourceConfig(name, logLevel);
+    SourceConfiguration sourceConfig;
+    sourceConfig.name = name;
+    sourceConfig.logLevel = logLevel;
 
     cfg.sourceSettings.push_back(sourceConfig);
 }
diff --git a/server/src/LoggingServer.cpp b/server/src/LoggingServer.cpp
index 1391929..83fb830 100644
--- a/server/src/LoggingServer.cpp
+++ b/server/src/LoggingServer.cpp
@@ -113,7 +113,9 @@ Configuration LoggingServerI::getConfiguration() const
     for (Sources::const_reverse_iterator i = mSources.rbegin(); i
              != mSources.rend(); ++i)
     {
-        SourceConfiguration v(i->first, i->second.getLogLevel());
+        SourceConfiguration v;
+        v.name = i->first;
+        v.logLevel =  i->second.getLogLevel();
         r.sourceSettings.push_back(v);
     }
     return r;

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


-- 
asterisk-scf/integration/logger.git



More information about the asterisk-scf-commits mailing list