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

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Wed Sep 29 09:41:01 CDT 2010


branch "master" has been updated
       via  3024590b1233c89e3e769fb65d67b01e1fd04bec (commit)
      from  8ce4322d4b18a28b6a3fdadae5f871f44ecd1764 (commit)

Summary of changes:
 client/src/IceLogger.cpp     |    2 +-
 client/src/Logger.cpp        |   21 +++++++--------------
 client/src/LoggerFactory.cpp |    5 ++---
 client/test/scf-log.cpp      |    2 +-
 server/src/ChainedLogOut.cpp |    5 +++--
 5 files changed, 14 insertions(+), 21 deletions(-)


- Log -----------------------------------------------------------------
commit 3024590b1233c89e3e769fb65d67b01e1fd04bec
Author: David M. Lee <dlee at digium.com>
Date:   Wed Sep 29 09:38:14 2010 -0500

    Fixed some warnings/errors for Windows build.

diff --git a/client/src/IceLogger.cpp b/client/src/IceLogger.cpp
index e65e486..a2c926f 100644
--- a/client/src/IceLogger.cpp
+++ b/client/src/IceLogger.cpp
@@ -71,7 +71,7 @@ void ConfiguredIceLogger::updateLoggerFromServiceLocator()
             logger.setServer(server);
          }
       }
-      catch (Core::Discovery::V1::ServiceNotFound const &r)
+      catch (Core::Discovery::V1::ServiceNotFound const &)
       {
          // couldn't find the service;
          logger.setServer(LoggingServerPrx());
diff --git a/client/src/Logger.cpp b/client/src/Logger.cpp
index 93558a4..84447d9 100644
--- a/client/src/Logger.cpp
+++ b/client/src/Logger.cpp
@@ -13,6 +13,8 @@
 
 using namespace AsteriskSCF::System::Logging;
 
+const int MESSAGE_SIZE = 120;
+
 LogBuf::LogBuf(LogOut &out, std::string const &name, Level logLevel) :
    out(out), name(name), logLevel(logLevel)
 {
@@ -90,20 +92,11 @@ void Logger::vlogf(Level level, char const *fmt, va_list ap) const
 {
    if (isEnabledFor(level))
    {
-      char *message = 0;
-      vasprintf(&message, fmt, ap);
-      if (message)
-      {
-         out->logs(name, level, message);
-         free(message);
-      }
-      else
-      {
-         // vasprintf failed to log our message.  At least send it somewhere
-         fprintf(stderr, "Failed to log: ");
-         vfprintf(stderr, fmt, ap);
-         fprintf(stderr, "\n");
-      }
+      char message[MESSAGE_SIZE];
+      vsnprintf(message, sizeof(message), fmt, ap);
+      // snprintf may not actually null terminate, so just in case
+      message[MESSAGE_SIZE - 1] = '\0';
+      out->logs(name, level, message);
    }
 }
 
diff --git a/client/src/LoggerFactory.cpp b/client/src/LoggerFactory.cpp
index 2b0dcd1..30a87cf 100644
--- a/client/src/LoggerFactory.cpp
+++ b/client/src/LoggerFactory.cpp
@@ -16,7 +16,6 @@
 
 #include <boost/algorithm/string/split.hpp>
 #include <boost/thread/once.hpp>
-
 #include "logger.h"
 
 using namespace AsteriskSCF::System::Logging;
@@ -30,8 +29,8 @@ LoggerFactory *loggerFactory = 0;
 
 void initLoggerFactory()
 {
-   static std::auto_ptr<LogOut> stdout = buildOstreamLogger(std::cout);
-   static LoggerFactory singleton(*stdout);
+   static std::auto_ptr<LogOut> out = buildOstreamLogger(std::cout);
+   static LoggerFactory singleton(*out);
    loggerFactory = &singleton;
 }
 
diff --git a/client/test/scf-log.cpp b/client/test/scf-log.cpp
index 672a87b..c4cbf25 100644
--- a/client/test/scf-log.cpp
+++ b/client/test/scf-log.cpp
@@ -7,7 +7,7 @@
  */
 
 #include <Ice/Ice.h>
-#include <unistd.h>
+//#include <unistd.h>
 
 #include "IceLogger.h"
 #include "logger.h"
diff --git a/server/src/ChainedLogOut.cpp b/server/src/ChainedLogOut.cpp
index 707ad5c..c96abd0 100644
--- a/server/src/ChainedLogOut.cpp
+++ b/server/src/ChainedLogOut.cpp
@@ -7,6 +7,7 @@
  */
 
 #include <iomanip>
+#include <ctime>
 
 #include "ChainedLogOut.h"
 
@@ -21,8 +22,8 @@ namespace
 std::string getCurrentTime()
 {
    char timeBuf[24];
-   time_t now = time(0);
-   strftime(timeBuf, sizeof(timeBuf), "%Y-%m-%d %H:%M:%S %Z", localtime(&now));
+   std::time_t now = std::time(0);
+   std::strftime(timeBuf, sizeof(timeBuf), "%Y-%m-%d %H:%M:%S %Z", std::localtime(&now));
    return timeBuf;
 }
 

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


-- 
asterisk-scf/integration/logger.git



More information about the asterisk-scf-commits mailing list