[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
Wed Dec 1 15:36:00 CST 2010


branch "master" has been updated
       via  7796f58cbd4bc1d5f0e32993afa54df6f2502ec0 (commit)
       via  09dc7e3800b6002ce7b00372e7292f3490805ccb (commit)
       via  c9c26d01efe6dce1518be4ff01969bfc9bdd214a (commit)
      from  cae06bbf5d29ce2f65761eb1092967d6a85b69a4 (commit)

Summary of changes:
 client/src/IceLogger.cpp     |    3 ++-
 client/src/Logger.cpp        |   22 ++++++++--------------
 client/src/LoggerFactory.cpp |    4 ++--
 client/src/logger.h          |    5 +++--
 server/src/LoggingServer.cpp |   11 ++++++-----
 server/src/LoggingServer.h   |    2 +-
 6 files changed, 22 insertions(+), 25 deletions(-)


- Log -----------------------------------------------------------------
commit 7796f58cbd4bc1d5f0e32993afa54df6f2502ec0
Author: David M. Lee <dlee at digium.com>
Date:   Wed Dec 1 15:05:34 2010 -0600

    Translated comments from gibberish to English.
    
    See CR-ASTSCF-4.

diff --git a/server/src/LoggingServer.cpp b/server/src/LoggingServer.cpp
index db2fd77..9ffd9eb 100644
--- a/server/src/LoggingServer.cpp
+++ b/server/src/LoggingServer.cpp
@@ -43,11 +43,12 @@ Level LoggingServerI::getEffectiveLevel(const std::string& name) const
     // thread safety
     IceUtil::Mutex::Lock sourcesLock(mSourcesMutex);
 
-    // this is they the map is reverse sorted.  find the first entry where
-    // the source key is a substring of the source we're looking for, where
-    // the substring
-    for (Sources::const_iterator i = mSources.lower_bound(name); i
-             != mSources.end(); ++i)
+    // the map is reverse sorted.  we're looking for the first entry where
+    // the source key is a subpath of name.  that would be the most specified
+    // configuration that matches the name we're looking for.
+    for (Sources::const_iterator i = mSources.lower_bound(name);
+         i != mSources.end();
+         ++i)
     {
         if (isSubpathOf(name, i->first))
         {
diff --git a/server/src/LoggingServer.h b/server/src/LoggingServer.h
index 72c1525..2e81a12 100644
--- a/server/src/LoggingServer.h
+++ b/server/src/LoggingServer.h
@@ -86,7 +86,7 @@ private:
     Sources;
 
     /**
-     * Returns true is subpath is a subpath of path.
+     * Returns true if paramater subpath is actually a subpath of path.
      *
      * @param path Full path to search.
      * @param subpath Subpath to look for.

commit 09dc7e3800b6002ce7b00372e7292f3490805ccb
Author: David M. Lee <dlee at digium.com>
Date:   Wed Dec 1 14:52:15 2010 -0600

    Replaced some manual memory management with shared_ptr.
    
    See CR-ASTSCF-4.

diff --git a/client/src/Logger.cpp b/client/src/Logger.cpp
index da48ffd..84291ff 100644
--- a/client/src/Logger.cpp
+++ b/client/src/Logger.cpp
@@ -78,13 +78,6 @@ Logger::Logger(const Logger& parent, const std::string& name) :
 Logger::~Logger()
 {
     IceUtil::Mutex::Lock childLock(mChildrenMutex);
-    for (std::map<std::string, Logger *>::iterator i = mChildren.begin();
-         i != mChildren.end();
-         ++i)
-    {
-        delete i->second;
-        i->second = 0;
-    }
 }
 
 CondStream Logger::operator()(Level level) const
@@ -124,8 +117,9 @@ void Logger::setOutput(LogOut& out)
 {
     this->mOut = &out;
     IceUtil::Mutex::Lock childLock(mChildrenMutex);
-    for (std::map<std::string, Logger *>::const_iterator i = mChildren.begin(); i
-             != mChildren.end(); ++i)
+    for (Children::const_iterator i = mChildren.begin();
+         i != mChildren.end();
+         ++i)
     {
         i->second->setOutput(out);
     }
@@ -161,21 +155,21 @@ Logger& Logger::getChild(const std::string& childName)
 {
     // ref to ptr allows us to update the map in-place
     IceUtil::Mutex::Lock childLock(mChildrenMutex);
-    Logger *&child = mChildren[childName];
+    boost::shared_ptr<Logger>& child = mChildren[childName];
     if (child == 0)
     {
         std::string fullName = getName().empty() ? childName : getName() + "."
             + childName;
-        child = new Logger(*this, fullName);
+        child.reset(new Logger(*this, fullName));
     }
     return *child;
 }
 
-std::vector<Logger const *> Logger::getChildren() const
+std::vector<boost::shared_ptr<const Logger> > Logger::getChildren() const
 {
-    std::vector<Logger const *> r;
+    std::vector<boost::shared_ptr<const Logger> > r;
     IceUtil::Mutex::Lock childLock(mChildrenMutex);
-    for (std::map<std::string, Logger *>::const_iterator i = mChildren.begin();
+    for (Children::const_iterator i = mChildren.begin();
          i != mChildren.end();
          ++i)
     {
diff --git a/client/src/LoggerFactory.cpp b/client/src/LoggerFactory.cpp
index daba661..81e349b 100644
--- a/client/src/LoggerFactory.cpp
+++ b/client/src/LoggerFactory.cpp
@@ -86,8 +86,8 @@ void LoggerFactory::accumulateLoggerNames(const Logger& logger,
 {
     out.push_back(logger.getName());
     // recurse through the children
-    const std::vector<const Logger*>& children = logger.getChildren();
-    for (std::vector<const Logger*>::const_iterator i = children.begin(); i
+    const std::vector<boost::shared_ptr<const Logger> >& children = logger.getChildren();
+    for (std::vector<boost::shared_ptr<const Logger> >::const_iterator i = children.begin(); i
              != children.end(); ++i)
     {
         accumulateLoggerNames(**i, out);
diff --git a/client/src/logger.h b/client/src/logger.h
index bf99202..90e79c5 100644
--- a/client/src/logger.h
+++ b/client/src/logger.h
@@ -193,7 +193,7 @@ public:
     }
 
     ASTERISK_SCF_ICEBOX_EXPORT Logger& getChild(const std::string& childName);
-    ASTERISK_SCF_ICEBOX_EXPORT std::vector<Logger const *> getChildren() const;
+    ASTERISK_SCF_ICEBOX_EXPORT std::vector<boost::shared_ptr<const Logger> > getChildren() const;
 
     ASTERISK_SCF_ICEBOX_EXPORT const std::string& getName() const
     {
@@ -238,10 +238,11 @@ private:
      * our parent.
      */
     Logger const * const mParent;
+    typedef std::map<std::string, boost::shared_ptr<Logger> > Children;
     /**
      * Map of children.  The key is the next final node in that child's name.
      */
-    std::map<std::string, Logger *> mChildren;
+    Children mChildren;
 
     /**
      * Name of this logger, in dotted-notation.

commit c9c26d01efe6dce1518be4ff01969bfc9bdd214a
Author: David M. Lee <dlee at digium.com>
Date:   Wed Dec 1 14:27:09 2010 -0600

    Professionalize an error message.
    
    See CR-ASTSCF-4.

diff --git a/client/src/IceLogger.cpp b/client/src/IceLogger.cpp
index 928cbd7..92cb0a4 100644
--- a/client/src/IceLogger.cpp
+++ b/client/src/IceLogger.cpp
@@ -51,7 +51,8 @@ void IceLogger::logs(const std::string& name, Level logLevel,
         if (!hasPrintedNoServerNotice) {
             hasPrintedNoServerNotice = true;
             std::clog <<
-                "!!! unable to log to server.  logging to stderr instead.\n";
+                "!!! Unable to log to server.  Please check configuration and server status.\n"
+                "!!! Logging to stderr instead.\n";
         }
         std::clog << name << ":" << logLevel << ":" << message << '\n';
     }

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


-- 
asterisk-scf/release/logger.git



More information about the asterisk-scf-commits mailing list