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

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Thu Sep 23 09:16:32 CDT 2010


branch "master" has been created
        at  edf236ccc7ed61007089f6c72711972d333357e1 (commit)

- Log -----------------------------------------------------------------
commit edf236ccc7ed61007089f6c72711972d333357e1
Author: David M. Lee <dlee at digium.com>
Date:   Wed Sep 22 16:27:30 2010 -0500

    Streaming output is working.  logger(Info) << "Working!";

diff --git a/client/src/Logger.cpp b/client/src/Logger.cpp
index aec08ad..7a6a27d 100644
--- a/client/src/Logger.cpp
+++ b/client/src/Logger.cpp
@@ -18,9 +18,48 @@ LogOut::~LogOut()
    // no-op
 }
 
+LogBuf::LogBuf(LogOut &out, std::string const &source, Level logLevel) :
+   out(out), source(source), logLevel(logLevel)
+{
+}
+
+LogBuf::LogBuf(LogBuf const &orig) :
+   out(orig.out), source(orig.source), logLevel(orig.logLevel)
+{
+   buffer.str(orig.buffer.str());
+}
+
+LogBuf::~LogBuf()
+{
+   if (!buffer.str().empty())
+   {
+      sendBuffer();
+   }
+}
+
+int LogBuf::overflow(int c)
+{
+   if (c == '\n' || c == traits_type::eof())
+   {
+      sendBuffer();
+      return c;
+   }
+   return buffer.sputc(c);
+}
+
+void LogBuf::sendBuffer()
+{
+   // logic looks a bit backwards, but that's in case out.logs()
+   // throws an exception, we still want to clear the buffer.
+   std::string const &message = buffer.str();
+   buffer.str("");
+   // send
+   out.logs(source, logLevel, message);
+}
+
+
 Logger::Logger(std::string const &name, LogOut &out, Level logLevel) :
-   parent(0), name(name), out(out), logLevel(logLevel),
-         inheritedLevel(false)
+   parent(0), name(name), out(out), logLevel(logLevel), inheritedLevel(false)
 {
 }
 
@@ -32,6 +71,11 @@ Logger::Logger(Logger const &parent, std::string const &name) :
    assert(name.find(parent.name) == 0);
 }
 
+CondStream Logger::operator()(Level level) const
+{
+   return CondStream(out, name, level, isEnabledFor(level));
+}
+
 void Logger::logs(Level level, std::string const &message) const
 {
    if (isEnabledFor(level))
@@ -99,8 +143,8 @@ Logger &Logger::getChild(std::string const &childName)
    Logger *&child = children[childName];
    if (child == 0)
    {
-      std::string fullName = getName().empty() ? childName
-         : getName() + "." + childName;
+      std::string fullName = getName().empty() ? childName : getName() + "."
+            + childName;
       child = new Logger(*this, fullName);
    }
    return *child;
diff --git a/client/src/logger.h b/client/src/logger.h
index ca5a867..01bfbb4 100644
--- a/client/src/logger.h
+++ b/client/src/logger.h
@@ -33,6 +33,95 @@ public:
 };
 
 /**
+ * A streambuf for writing to a LogOut.  Messages are written at newlines (\n)
+ * or when destroyed.  The way temporary object lifecycles work in C++, this is
+ * very convenient.
+ */
+class LogBuf : public std::streambuf
+{
+public:
+   LogBuf(LogOut &out, std::string const &source, Level logLevel);
+
+   /**
+    * Copy ctor.
+    * @param orig Original.
+    */
+   LogBuf(LogBuf const &orig);
+
+   ~LogBuf();
+
+protected:
+   int overflow(int c);
+
+private:
+   std::stringbuf buffer;
+   LogOut &out;
+   const std::string source;
+   const Level logLevel;
+
+   /**
+    * Sends the current buffer to out and clears it.
+    */
+   void sendBuffer();
+};
+
+/**
+ * A ostream-like thing which will only process output if enabled.  When
+ * disabled, it very efficiently ignores operator<<() calls.
+ */
+class CondStream
+{
+public:
+   CondStream(LogOut &out, std::string const &source, Level logLevel,
+              bool enabled) :
+      buf(out, source, logLevel), stream(&buf), enabled(enabled)
+   {
+   }
+
+   /**
+    * Copy ctor.
+    * @param orig Original.
+    */
+   CondStream(CondStream const &orig) :
+      buf(orig.buf), stream(&buf), enabled(orig.enabled)
+   {
+
+   }
+
+   /**
+    * Output operator.  Only does something when enabled == true.
+    * @param val Value to output.
+    * @return this.
+    */
+   template<typename T>
+   CondStream &operator<<(T const &val);
+
+private:
+   /**
+    * streambuffer for writing characters.
+    */
+   LogBuf buf;
+   /**
+    * Ostream for processing output.
+    */
+   std::ostream stream;
+   /**
+    * If false, operator<<() does nothing.
+    */
+   bool enabled;
+};
+
+template<typename T>
+inline CondStream &CondStream::operator<<(T const &val)
+{
+   if (enabled)
+   {
+      stream << val;
+   }
+   return *this;
+}
+
+/**
  * The Logger for a particular Source.
  */
 class Logger
@@ -60,6 +149,14 @@ public:
    }
 
    /**
+    * Ostream style logging.
+    *
+    * @param level Level for messages sent to this stream.
+    * @return LogStream that logs at the given level.
+    */
+   CondStream operator()(Level level) const;
+
+   /**
     * Log a single message.
     */
    void logs(Level level, std::string const &message) const;
diff --git a/client/test/CMakeLists.txt b/client/test/CMakeLists.txt
index b7d8bbf..099d451 100644
--- a/client/test/CMakeLists.txt
+++ b/client/test/CMakeLists.txt
@@ -13,6 +13,7 @@ include_directories(../../common)
 
 hydra_component_add_file(logging-client-test Logger-test.cpp)
 hydra_component_add_file(logging-client-test LoggerFactory-test.cpp)
+hydra_component_add_file(logging-client-test LogBuf-test.cpp)
 hydra_component_add_file(logging-client-test client-test.cpp)
 
 hydra_component_add_boost_libraries(logging-client-test unit_test_framework)
diff --git a/client/test/ExpectedLogOut.h b/client/test/ExpectedLogOut.h
new file mode 100644
index 0000000..a7a051e
--- /dev/null
+++ b/client/test/ExpectedLogOut.h
@@ -0,0 +1,50 @@
+/*
+ * Asterisk Scalable Communications Framework
+ *
+ * Copyright (C) 2010 -- Digium, Inc.
+ *
+ * All rights reserved.
+ */
+
+#pragma once
+
+#include "logger.h"
+
+namespace AsteriskSCF
+{
+namespace System
+{
+namespace Logging
+{
+
+/**
+ * Mock class to check the output that makes it to a LogOut interface.
+ */
+class ExpectedLogOut : public LogOut
+{
+public:
+   ExpectedLogOut(std::string const &expected) :
+      expected(expected)
+   {
+   }
+
+   void logs(std::string const &source, Level logLevel,
+             std::string const &message)
+   {
+      actual << source << ":" << logLevel << ":" << message << '\n';
+   }
+
+   void check()
+   {
+      BOOST_CHECK_EQUAL(expected, actual.str());
+   }
+
+private:
+   std::string expected;
+   std::stringstream actual;
+};
+
+
+} // Logging
+} // System
+} // AsteriskSCF
diff --git a/client/test/LogBuf-test.cpp b/client/test/LogBuf-test.cpp
new file mode 100644
index 0000000..8979aef
--- /dev/null
+++ b/client/test/LogBuf-test.cpp
@@ -0,0 +1,39 @@
+/*
+ * Asterisk Scalable Communications Framework
+ *
+ * Copyright (C) 2010 -- Digium, Inc.
+ *
+ * All rights reserved.
+ */
+
+
+#include <boost/test/unit_test.hpp>
+
+#include "logger.h"
+#include "ExpectedLogOut.h"
+
+using namespace AsteriskSCF::System::Logging;
+
+BOOST_AUTO_TEST_SUITE(LogStreamTest)
+
+BOOST_AUTO_TEST_CASE(test_stream)
+{
+   ExpectedLogOut out("src:Info:testing\n");
+   LogBuf uut(out, "src", Info);
+   std::ostream stream(&uut);
+
+   stream << "testing" << '\n';
+   out.check();
+}
+
+BOOST_AUTO_TEST_CASE(test_stream_format)
+{
+   ExpectedLogOut out("src:Debug:debug f00d\n");
+   LogBuf buf(out, "src", Debug);
+   std::ostream uut(&buf);
+
+   uut << "debug " << std::hex << 61453 << '\n';
+   out.check();
+}
+
+BOOST_AUTO_TEST_SUITE_END()
diff --git a/client/test/Logger-test.cpp b/client/test/Logger-test.cpp
index 2984862..0216dcd 100644
--- a/client/test/Logger-test.cpp
+++ b/client/test/Logger-test.cpp
@@ -6,41 +6,13 @@
  * All rights reserved.
  */
 
-#include <sstream>
-
 #include <boost/test/unit_test.hpp>
 
 #include "logger.h"
+#include "ExpectedLogOut.h"
 
 using namespace AsteriskSCF::System::Logging;
 
-namespace
-{
-class ExpectedLogOut : public LogOut
-{
-public:
-   ExpectedLogOut(std::string const &expected) :
-      expected(expected)
-   {
-   }
-
-   void logs(std::string const &source, Level logLevel,
-             std::string const &message)
-   {
-      actual << source << ":" << logLevel << ":" << message << '\n';
-   }
-
-   void check()
-   {
-      BOOST_CHECK_EQUAL(expected, actual.str());
-   }
-
-private:
-   std::string expected;
-   std::stringstream actual;
-};
-}
-
 BOOST_AUTO_TEST_SUITE( LoggerTest )
 
 BOOST_AUTO_TEST_CASE( test_log )
@@ -79,4 +51,50 @@ BOOST_AUTO_TEST_CASE( test_log_squelched )
    out.check();
 }
 
+BOOST_AUTO_TEST_CASE(test_stream_on)
+{
+   ExpectedLogOut out("src:Debug:debug\n");
+   Logger uut("src", out, Debug);
+
+   uut(Debug) << "debug\n";
+   out.check();
+}
+
+BOOST_AUTO_TEST_CASE(test_stream_off)
+{
+   ExpectedLogOut out("");
+   Logger uut("src", out, Info);
+
+   uut(Debug) << "debug\n";
+   out.check();
+}
+
+BOOST_AUTO_TEST_CASE(test_stream)
+{
+   ExpectedLogOut out("src:Info:testing\n");
+   Logger uut("src", out, Info);
+
+   uut(Info) << "testing" << '\n';
+   out.check();
+}
+
+BOOST_AUTO_TEST_CASE(test_stream_format)
+{
+   ExpectedLogOut out("src:Debug:debug f00d\n");
+   Logger uut("src", out, Debug);
+
+   uut(Debug) << "debug " << std::hex << 61453 << '\n';
+   out.check();
+}
+
+BOOST_AUTO_TEST_CASE(test_stream_lots)
+{
+   ExpectedLogOut out("src:Debug:debug\nsrc:Info:info\n");
+   Logger uut("src", out, Debug);
+
+   uut(Debug) << "debug";
+   uut(Info) << "info";
+   out.check();
+}
+
 BOOST_AUTO_TEST_SUITE_END()

commit c5f96ec0447f23b6aaca938d28efc91c7171f957
Author: David M. Lee <dlee at digium.com>
Date:   Wed Sep 22 16:26:53 2010 -0500

    Server-side clean ups.

diff --git a/server/src/LoggingServer.cpp b/server/src/LoggingServer.cpp
index 5fc8a37..0045fb6 100644
--- a/server/src/LoggingServer.cpp
+++ b/server/src/LoggingServer.cpp
@@ -44,32 +44,13 @@ Level LoggingServerI::getEffectiveLevel(std::string const &source) const
    // 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
-   Sources::const_iterator i = sources.lower_bound(source);
-
-   while (i != sources.end())
+   for (Sources::const_iterator i = sources.lower_bound(source);
+         i != sources.end(); ++i)
    {
-      std::string const &key = i->first;
-      // if key is subkey of source
-      // avoid coincidental matches (i.e. "A" is not a subkey of "AA")
-      if (source.compare(0, key.size(), key) == 0)
+      if (isSubpathOf(source, i->first))
       {
-         if (source.size() == key.size())
-         {
-            // exact match
-            return i->second.getLevel();
-         }
-         if (key.empty())
-         {
-            // matches default setting
-            return i->second.getLevel();
-         }
-         if (source[key.length()] == '.')
-         {
-            // matches subkey
-            return i->second.getLevel();
-         }
+         return i->second.getLevel();
       }
-      ++i;
    }
 
    // Since "" is in the map, this should never run.
@@ -88,22 +69,53 @@ void LoggingServerI::logs(std::string const &source, Level level,
 {
    if (isEnabledFor(source, level))
    {
-      // date level source(1) message
-      std::string::size_type lastDot = source.rfind('.');
-      if (lastDot == std::string::npos)
+      reallyLog(source, level, message);
+   }
+}
+
+void LoggingServerI::reallyLog(std::string const &source, Level level,
+                               const std::string &message) const
+{
+   // date level source(1) message
+   std::string::size_type lastDot = source.rfind('.');
+   if (lastDot == std::string::npos)
+   {
+      lastDot = -1;
+   }
+   std::string lastSource = source.substr(lastDot + 1);
+   {
+      IceUtil::Mutex::Lock sourcesLock(outputMutex);
+      std::ostream::fmtflags flags = std::cout.flags();
+      std::cout << getCurrentTime() << ' ' << std::setw(9) << level << ' '
+            << std::setw(9) << std::left << lastSource << ' ' << message
+            << '\n';
+      std::cout.flags(flags);
+   }
+}
+
+bool LoggingServerI::isSubpathOf(std::string const &path,
+                                 std::string const &subpath)
+{
+   // if path begins with subpath
+   if (path.compare(0, subpath.size(), subpath) == 0)
+   {
+      // if matched default setting
+      if (subpath.empty())
+      {
+         return true;
+      }
+      // if exact match
+      if (path.size() == subpath.size())
       {
-         lastDot = -1;
+         return true;
       }
-      std::string lastSource = source.substr(lastDot + 1);
+      // if subpath
+      if (path[subpath.length()] == '.')
       {
-         IceUtil::Mutex::Lock sourcesLock(outputMutex);
-         std::ostream::fmtflags flags = std::cout.flags();
-         std::cout << getCurrentTime() << ' ' << std::setw(9) << level << ' '
-               << std::setw(9) << std::left << lastSource << ' ' << message
-               << '\n';
-         std::cout.flags(flags);
+         return true;
       }
    }
+   return false;
 }
 
 // <prefix>.logger=level
diff --git a/server/src/LoggingServer.h b/server/src/LoggingServer.h
index 12ebd89..6d9eeb9 100644
--- a/server/src/LoggingServer.h
+++ b/server/src/LoggingServer.h
@@ -75,6 +75,20 @@ private:
    typedef std::map<std::string, SourceNode, std::greater<std::string> >
          Sources;
 
+   /**
+    * Unconditionally logs the given message.
+    */
+   void reallyLog(std::string const &, Level, const std::string&) const;
+
+   /**
+    * Returns true is subpath is a subpath of path.
+    *
+    * @param path Full path to search.
+    * @param subpath Subpath to look for.
+    * @return true if subpath is a subpath of path.
+    */
+   static bool isSubpathOf(std::string const &path, std::string const &subpath);
+
    IceUtil::Mutex sourcesMutex;
    IceUtil::Mutex outputMutex;
    Sources sources;

commit f3db9df597ca5af93fe984189ba0330945cd4639
Author: David M. Lee <dlee at digium.com>
Date:   Wed Sep 22 10:59:11 2010 -0500

    Commented Level's

diff --git a/ice/log4scf.ice b/ice/log4scf.ice
index 6a2ffc5..c70909f 100644
--- a/ice/log4scf.ice
+++ b/ice/log4scf.ice
@@ -19,14 +19,23 @@ module Logging
     */
    enum Level
    {
+      /** debug-level messages */
       Debug,
+      /** informational messages */
       Info,
+      /** normal but significant condition */
       Notice,
+      /** warning conditions */
       Warning,
+      /** error conditions */
       Error,
+      /** critical conditions */
       Critical,
+      /** action must be taken immediately */
       Alert,
+      /** system is unusable */
       Emergency,
+      /** phony level; only to be used in setting log levels */
       Off
    };
 

commit 034f0e6656c09939da144efbb76a57408f522fc5
Author: David M. Lee <dlee at digium.com>
Date:   Wed Sep 22 09:28:09 2010 -0500

    Commented most recent change, to avoid overzealous optimization in the future.

diff --git a/client/src/LoggerFactory.cpp b/client/src/LoggerFactory.cpp
index 7e52698..4bf03cb 100644
--- a/client/src/LoggerFactory.cpp
+++ b/client/src/LoggerFactory.cpp
@@ -29,6 +29,8 @@ LoggerFactory::LoggerFactory(LogOut &out) :
 Logger &LoggerFactory::getLogger(std::string const &source)
 {
    std::vector<std::string> path;
+   // older versions of boost output a single entry when splitting an empty
+   // string
    if (!source.empty())
    {
       split(path, source, std::bind1st(std::equal_to<char>(), '.'));

commit 68bc29e4bb2cf9f390df51d1f7f3ed1d7ee3fd6f
Author: David M. Lee <dlee at digium.com>
Date:   Wed Sep 22 09:42:54 2010 -0500

    copy/paste error.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1c2faee..4c2a3c4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -17,7 +17,7 @@ if(NOT integrated_build STREQUAL "true")
    include(cmake/AsteriskSCF.cmake)
 
    # This project is C++ based and requires a minimum of 3.4
-   hydra_project("bridging service" 3.4 CXX)
+   hydra_project("log4scf" 3.4 CXX)
 
 endif()
 

commit acd159b69547a9b446e163af06c0fdc7a4d51fb7
Author: David M. Lee <dlee at digium.com>
Date:   Wed Sep 22 09:17:28 2010 -0500

    Fixed bug on Linux.  string.split() works differently on an empty string.

diff --git a/client/src/LoggerFactory.cpp b/client/src/LoggerFactory.cpp
index 5ea4689..7e52698 100644
--- a/client/src/LoggerFactory.cpp
+++ b/client/src/LoggerFactory.cpp
@@ -29,7 +29,10 @@ LoggerFactory::LoggerFactory(LogOut &out) :
 Logger &LoggerFactory::getLogger(std::string const &source)
 {
    std::vector<std::string> path;
-   split(path, source, std::bind1st(std::equal_to<char>(), '.'));
+   if (!source.empty())
+   {
+      split(path, source, std::bind1st(std::equal_to<char>(), '.'));
+   }
 
    Logger *logger = &root;
    for (std::vector<std::string>::iterator i = path.begin(); i != path.end(); ++i)

commit ad4240ebad303c6089d8d5ef3376b16027cd9dc7
Author: David M. Lee <dlee at digium.com>
Date:   Tue Sep 21 16:58:08 2010 -0500

    Clean-up and comment on the client side.

diff --git a/client/src/Logger.cpp b/client/src/Logger.cpp
index 41dd12f..aec08ad 100644
--- a/client/src/Logger.cpp
+++ b/client/src/Logger.cpp
@@ -32,11 +32,6 @@ Logger::Logger(Logger const &parent, std::string const &name) :
    assert(name.find(parent.name) == 0);
 }
 
-Logger::~Logger()
-{
-   // no-op
-}
-
 void Logger::logs(Level level, std::string const &message) const
 {
    if (isEnabledFor(level))
diff --git a/client/src/logger.h b/client/src/logger.h
index fbd4026..ca5a867 100644
--- a/client/src/logger.h
+++ b/client/src/logger.h
@@ -38,12 +38,16 @@ public:
 class Logger
 {
 public:
+   /**
+    * Construct a root Logger.
+    */
    Logger(std::string const &name, LogOut &out, Level logLevel = Debug);
 
+   /**
+    * Construct a child Logger.
+    */
    Logger(Logger const &parent, std::string const &name);
 
-   virtual ~Logger();
-
    /**
     * If true, this Logger would log messages of the given Level.
     *
@@ -70,7 +74,6 @@ public:
     */
    void vlogf(Level level, char const *fmt, va_list ap) const;
 
-
    Logger const *getParent() const
    {
       return parent;
@@ -88,8 +91,15 @@ public:
       return out;
    }
 
+   /**
+    * Set's the current logLevel.  Until unsetLevel() is called, we are no
+    * longer affected by changes to our parent's log level.
+    */
    void setLevel(Level logLevel);
 
+   /**
+    * Changes our logLevel to now inherit from out parent.
+    */
    void unsetLevel();
 
    /**
@@ -105,9 +115,21 @@ private:
    Logger const *parent;
    std::map<std::string, Logger *> children;
 
+   /**
+    * Name of this logger, in dotted-notation.
+    */
    const std::string name;
+   /**
+    * Output for log messages.
+    */
    LogOut &out;
+   /**
+    * Current level of this Logger.  Only applicable if inheritedLevel == false.
+    */
    Level logLevel;
+   /**
+    * If true, then our effectiveLevel == parent->effectiveLevel.
+    */
    bool inheritedLevel;
 };
 

commit 8c39120b4fd70063a64242748d5957ee08899f71
Author: David M. Lee <dlee at digium.com>
Date:   Tue Sep 21 16:51:34 2010 -0500

    Got rid of some over-the-top inlining.

diff --git a/client/src/Logger.cpp b/client/src/Logger.cpp
index f84c992..41dd12f 100644
--- a/client/src/Logger.cpp
+++ b/client/src/Logger.cpp
@@ -18,6 +18,19 @@ LogOut::~LogOut()
    // no-op
 }
 
+Logger::Logger(std::string const &name, LogOut &out, Level logLevel) :
+   parent(0), name(name), out(out), logLevel(logLevel),
+         inheritedLevel(false)
+{
+}
+
+Logger::Logger(Logger const &parent, std::string const &name) :
+   parent(&parent), name(name), out(parent.out), logLevel(Off),
+         inheritedLevel(true)
+{
+   // our name must begin w/ parent's name
+   assert(name.find(parent.name) == 0);
+}
 
 Logger::~Logger()
 {
@@ -60,6 +73,31 @@ void Logger::vlogf(Level level, char const *fmt, va_list ap) const
    }
 }
 
+void Logger::setLevel(Level logLevel)
+{
+   this->logLevel = logLevel;
+   inheritedLevel = false;
+}
+
+void Logger::unsetLevel()
+{
+   logLevel = Off;
+   inheritedLevel = true;
+}
+
+Level Logger::getEffectiveLevel() const
+{
+   // if our level is unset, inherit level from our parent.
+   if (inheritedLevel == true && parent != 0)
+   {
+      return parent->getEffectiveLevel();
+   }
+   else
+   {
+      return logLevel;
+   }
+}
+
 Logger &Logger::getChild(std::string const &childName)
 {
    // ref to ptr allows us to update the map in-place
diff --git a/client/src/logger.h b/client/src/logger.h
index b03dbb7..fbd4026 100644
--- a/client/src/logger.h
+++ b/client/src/logger.h
@@ -38,19 +38,10 @@ public:
 class Logger
 {
 public:
-   Logger(std::string const &name, LogOut &out, Level logLevel = Debug) :
-      parent(0), name(name), out(out), logLevel(logLevel),
-            inheritedLevel(false)
-   {
-   }
+   Logger(std::string const &name, LogOut &out, Level logLevel = Debug);
+
+   Logger(Logger const &parent, std::string const &name);
 
-   Logger(Logger const &parent, std::string const &name) :
-      parent(&parent), name(name), out(parent.out), logLevel(Off),
-            inheritedLevel(true)
-   {
-      // our name must begin w/ parent's name
-      assert(name.find(parent.name) == 0);
-   }
    virtual ~Logger();
 
    /**
@@ -79,47 +70,32 @@ public:
     */
    void vlogf(Level level, char const *fmt, va_list ap) const;
 
+
+   Logger const *getParent() const
+   {
+      return parent;
+   }
+
+   Logger &getChild(std::string const &childName);
+
    std::string const &getName() const
    {
       return name;
    }
+
    LogOut &getOutput() const
    {
       return out;
    }
 
-   void setLevel(Level logLevel)
-   {
-      this->logLevel = logLevel;
-      inheritedLevel = false;
-   }
+   void setLevel(Level logLevel);
 
-   void unsetLevel()
-   {
-      logLevel = Off;
-      inheritedLevel = true;
-   }
+   void unsetLevel();
 
    /**
     * Returns the effective level of this Logger.
     */
-   Level getEffectiveLevel() const
-   {
-      if (inheritedLevel == true && parent != 0)
-      {
-         return parent->getEffectiveLevel();
-      }
-      else
-      {
-         return logLevel;
-      }
-   }
-
-   Logger const *getParent() const
-   {
-      return parent;
-   }
-   Logger &getChild(std::string const &childName);
+   Level getEffectiveLevel() const;
 
 private:
    // non-copyable

commit 1bef67a454a6434fee76809f1409e85491f71b3c
Author: David M. Lee <dlee at digium.com>
Date:   Tue Sep 21 16:31:36 2010 -0500

    Removed debug sleep().  Left justify the source.

diff --git a/server/src/LoggingServer.cpp b/server/src/LoggingServer.cpp
index b38a5b8..5fc8a37 100644
--- a/server/src/LoggingServer.cpp
+++ b/server/src/LoggingServer.cpp
@@ -86,7 +86,6 @@ void LoggingServerI::setLevel(std::string const &source, Level level)
 void LoggingServerI::logs(std::string const &source, Level level,
                           const std::string &message, const Ice::Current&) const
 {
-   sleep(3);
    if (isEnabledFor(source, level))
    {
       // date level source(1) message
@@ -98,8 +97,11 @@ void LoggingServerI::logs(std::string const &source, Level level,
       std::string lastSource = source.substr(lastDot + 1);
       {
          IceUtil::Mutex::Lock sourcesLock(outputMutex);
+         std::ostream::fmtflags flags = std::cout.flags();
          std::cout << getCurrentTime() << ' ' << std::setw(9) << level << ' '
-               << std::setw(9) << lastSource << ' ' << message << '\n';
+               << std::setw(9) << std::left << lastSource << ' ' << message
+               << '\n';
+         std::cout.flags(flags);
       }
    }
 }

commit 4b4661d7922d7dda17e696006482e902c2c0a401
Author: David M. Lee <dlee at digium.com>
Date:   Tue Sep 21 16:26:37 2010 -0500

    Fixed bug when source has a single node.

diff --git a/server/src/LoggingServer.cpp b/server/src/LoggingServer.cpp
index af80efe..b38a5b8 100644
--- a/server/src/LoggingServer.cpp
+++ b/server/src/LoggingServer.cpp
@@ -93,7 +93,7 @@ void LoggingServerI::logs(std::string const &source, Level level,
       std::string::size_type lastDot = source.rfind('.');
       if (lastDot == std::string::npos)
       {
-         lastDot = 0;
+         lastDot = -1;
       }
       std::string lastSource = source.substr(lastDot + 1);
       {

commit 4677228d94e2eca4cf7a6dece7b3609bb9732941
Author: David M. Lee <dlee at digium.com>
Date:   Tue Sep 21 16:21:00 2010 -0500

    scf-log now takes command line parameters

diff --git a/client/test/scf-log.cpp b/client/test/scf-log.cpp
index 058ea03..0d51754 100644
--- a/client/test/scf-log.cpp
+++ b/client/test/scf-log.cpp
@@ -7,39 +7,83 @@
  */
 
 #include <Ice/Ice.h>
+#include <unistd.h>
 
 #include "logger.h"
 
 using namespace AsteriskSCF::System::Logging;
 
-int main(int argc, char *argv[])
+namespace
 {
-   int status = 0;
-   Ice::CommunicatorPtr ic;
-   try
-   {
-      ic = Ice::initialize(argc, argv);
-      Ice::ObjectPrx base = ic->stringToProxy("LoggingServer:default -p 10000");
-      LoggingServerPrx logger = LoggingServerPrx::checkedCast(base);
-      if (!logger)
-         throw "Invalid proxy";
 
-      std::auto_ptr<LogOut> logOut = buildIceLogger(logger);
-      LoggerFactory factory(*logOut);
+class ScfLogClientApplication : public Ice::Application
+{
+public:
+   int run(int argc, char *argv[]);
+   void usage(std::ostream &out);
+};
 
-      factory.getLogger("AsteriskSCF.System.Logger").logs(Debug, "Hello, Asterisk-SCF");
+} // namespace
+
+int ScfLogClientApplication::run(int argc, char *argv[])
+{
+   std::string source = "AsteriskSCF.System.Logger";
+   Level level = Info;
+   std::string message;
+   int ch;
+   while ((ch = getopt(argc, argv, "p:t:")) != -1)
+   {
+      switch (ch)
+      {
+      case 'p':
+         level = parseString(optarg);
+         break;
+      case 't':
+         source = std::string(optarg);
+         break;
+      case '?':
+         usage(std::cout);
+         return EXIT_SUCCESS;
+      default:
+         usage(std::clog);
+         return EXIT_FAILURE;
+      }
    }
-   catch (const Ice::Exception& ex)
+   argc -= optind;
+   argv += optind;
+
+   while (argc-- > 0)
    {
-      std::cerr << ex << '\n';
-      status = 1;
+      message += std::string(argv[0]) + " ";
+      ++argv;
    }
-   catch (const char* msg)
+
+   if (message.empty())
    {
-      std::cerr << msg << '\n';
-      status = 1;
+      // don't log empty messages
+      return EXIT_SUCCESS;
    }
-   if (ic)
-      ic->destroy();
-   return status;
+
+   Ice::ObjectPrx base =
+         communicator()->stringToProxy("LoggingServer:default -p 10000");
+   LoggingServerPrx logger = LoggingServerPrx::checkedCast(base);
+   if (!logger)
+      throw "Invalid proxy";
+
+   std::auto_ptr<LogOut> logOut = buildIceLogger(logger);
+   LoggerFactory factory(*logOut);
+
+   factory.getLogger(source).logs(level, message);
+   return EXIT_SUCCESS;
+}
+
+void ScfLogClientApplication::usage(std::ostream &out)
+{
+   out << "Usage: scf-log [-p pri] [-t tag] message...\n";
+}
+
+int main(int argc, char *argv[])
+{
+   ScfLogClientApplication app;
+   return app.main(argc, argv);
 }

commit b5578075c8a975bc16f876a733157fc1e2192f7e
Author: David M. Lee <dlee at digium.com>
Date:   Tue Sep 21 16:20:09 2010 -0500

    Server thread safety.

diff --git a/server/src/LoggingServer.cpp b/server/src/LoggingServer.cpp
index ba7bad9..af80efe 100644
--- a/server/src/LoggingServer.cpp
+++ b/server/src/LoggingServer.cpp
@@ -29,11 +29,18 @@ std::string getCurrentTime()
 
 } // namespace
 
-const std::string LoggingServerI::LoggingPropertyPrefix =
-      "AsteriskSCF.Logging";
+const std::string LoggingServerI::LoggingPropertyPrefix = "AsteriskSCF.Logging";
+
+bool LoggingServerI::isEnabledFor(std::string const &source, Level level) const
+{
+   return getEffectiveLevel(source) <= level;
+}
 
 Level LoggingServerI::getEffectiveLevel(std::string const &source) const
 {
+   // thread safety
+   IceUtil::Mutex::Lock sourcesLock(sourcesMutex);
+
    // 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
@@ -71,13 +78,15 @@ Level LoggingServerI::getEffectiveLevel(std::string const &source) const
 
 void LoggingServerI::setLevel(std::string const &source, Level level)
 {
+   // thread safety
+   IceUtil::Mutex::Lock sourcesLock(sourcesMutex);
    sources[source].setLevel(level);
 }
 
 void LoggingServerI::logs(std::string const &source, Level level,
                           const std::string &message, const Ice::Current&) const
 {
-
+   sleep(3);
    if (isEnabledFor(source, level))
    {
       // date level source(1) message
@@ -87,8 +96,11 @@ void LoggingServerI::logs(std::string const &source, Level level,
          lastDot = 0;
       }
       std::string lastSource = source.substr(lastDot + 1);
-      std::cout << getCurrentTime() << ' ' << std::setw(9) << level << ' '
-            << std::setw(9) << lastSource << ' ' << message << '\n';
+      {
+         IceUtil::Mutex::Lock sourcesLock(outputMutex);
+         std::cout << getCurrentTime() << ' ' << std::setw(9) << level << ' '
+               << std::setw(9) << lastSource << ' ' << message << '\n';
+      }
    }
 }
 
@@ -96,15 +108,17 @@ void LoggingServerI::logs(std::string const &source, Level level,
 // <prefix>.logger.<source>=level
 void LoggingServerI::configure(Ice::PropertiesPtr props)
 {
+   // thread safety
+   IceUtil::Mutex::Lock sourcesLock(sourcesMutex);
+
    Ice::PropertyDict myProps =
          props->getPropertiesForPrefix(LoggingPropertyPrefix);
 
    const std::string rootLogger = LoggingPropertyPrefix + ".logger";
    const std::string logger = LoggingPropertyPrefix + ".logger.";
 
-   for (Ice::PropertyDict::const_iterator i = myProps.begin();
-         i != myProps.end();
-         ++i)
+   for (Ice::PropertyDict::const_iterator i = myProps.begin(); i
+         != myProps.end(); ++i)
    {
       if (i->first == rootLogger)
       {
diff --git a/server/src/LoggingServer.h b/server/src/LoggingServer.h
index 3df12ca..12ebd89 100644
--- a/server/src/LoggingServer.h
+++ b/server/src/LoggingServer.h
@@ -62,10 +62,7 @@ public:
    void logs(std::string const &, Level, const std::string&,
              const Ice::Current&) const;
 
-   bool isEnabledFor(std::string const &source, Level level) const
-   {
-      return getEffectiveLevel(source) <= level;
-   }
+   bool isEnabledFor(std::string const &source, Level level) const;
    Level getEffectiveLevel(std::string const &source) const;
    void setLevel(std::string const &source, Level level);
 
@@ -78,6 +75,8 @@ private:
    typedef std::map<std::string, SourceNode, std::greater<std::string> >
          Sources;
 
+   IceUtil::Mutex sourcesMutex;
+   IceUtil::Mutex outputMutex;
    Sources sources;
 };
 

commit dcdb57a2132a825372a1d75243e05b1962c3b4b3
Author: David M. Lee <dlee at digium.com>
Date:   Tue Sep 21 16:19:16 2010 -0500

    Use a oneway proxy from the client.

diff --git a/client/src/IceLogger.cpp b/client/src/IceLogger.cpp
index a669ad7..be0e576 100644
--- a/client/src/IceLogger.cpp
+++ b/client/src/IceLogger.cpp
@@ -17,7 +17,8 @@ class IceLogger : public LogOut
 {
 public:
    IceLogger(LoggingServerPrx const &server) :
-      server(server)
+      // convert our proxy to a oneway proxy, so we don't block on invocations
+      server(server->ice_oneway())
    {
    }
 

commit 6a804e279ef053bf9d31034ce53d1957e80f793a
Author: David M. Lee <dlee at digium.com>
Date:   Tue Sep 21 14:46:20 2010 -0500

    Server is now configured via Ice properties.

diff --git a/server/src/LoggingServer.cpp b/server/src/LoggingServer.cpp
index 0cd59ae..ba7bad9 100644
--- a/server/src/LoggingServer.cpp
+++ b/server/src/LoggingServer.cpp
@@ -29,6 +29,9 @@ std::string getCurrentTime()
 
 } // namespace
 
+const std::string LoggingServerI::LoggingPropertyPrefix =
+      "AsteriskSCF.Logging";
+
 Level LoggingServerI::getEffectiveLevel(std::string const &source) const
 {
    // this is they the map is reverse sorted.  find the first entry where
@@ -89,3 +92,32 @@ void LoggingServerI::logs(std::string const &source, Level level,
    }
 }
 
+// <prefix>.logger=level
+// <prefix>.logger.<source>=level
+void LoggingServerI::configure(Ice::PropertiesPtr props)
+{
+   Ice::PropertyDict myProps =
+         props->getPropertiesForPrefix(LoggingPropertyPrefix);
+
+   const std::string rootLogger = LoggingPropertyPrefix + ".logger";
+   const std::string logger = LoggingPropertyPrefix + ".logger.";
+
+   for (Ice::PropertyDict::const_iterator i = myProps.begin();
+         i != myProps.end();
+         ++i)
+   {
+      if (i->first == rootLogger)
+      {
+         setLevel("", parseString(i->second));
+      }
+      else if (i->first.find(logger) == 0)
+      {
+         std::string const &source = i->first.substr(logger.size());
+         setLevel(source, parseString(i->second));
+      }
+      else
+      {
+         std::cerr << "Unknown logger property: " << i->first << '\n';
+      }
+   }
+}
diff --git a/server/src/LoggingServer.h b/server/src/LoggingServer.h
index babd0b9..3df12ca 100644
--- a/server/src/LoggingServer.h
+++ b/server/src/LoggingServer.h
@@ -12,6 +12,8 @@
 #include <functional>
 #include <string>
 
+#include <Ice/Properties.h>
+
 #include "log4scf.h"
 
 namespace AsteriskSCF
@@ -67,6 +69,10 @@ public:
    Level getEffectiveLevel(std::string const &source) const;
    void setLevel(std::string const &source, Level level);
 
+   void configure(Ice::PropertiesPtr props);
+
+   static const std::string LoggingPropertyPrefix;
+
 private:
    /** Keep sources in a revers-sorted map. */
    typedef std::map<std::string, SourceNode, std::greater<std::string> >
diff --git a/server/src/main.cpp b/server/src/main.cpp
index 2093d1e..5c7af21 100644
--- a/server/src/main.cpp
+++ b/server/src/main.cpp
@@ -6,6 +6,7 @@
  * All rights reserved.
  */
 
+#include <Ice/Properties.h>
 #include <Ice/Service.h>
 
 #include "LoggingServer.h"
@@ -16,17 +17,36 @@ namespace
 {
 class LoggingServerDaemon : public Ice::Service
 {
+public:
    bool start(int argc, char *argv[], int &status);
+private:
 };
+
+Ice::PropertiesPtr parseCommandLine(int &argc, char *argv[])
+{
+   Ice::PropertiesPtr props = Ice::createProperties();
+   std::vector<std::string> args(argc);
+   for (int i = 0; i < argc; ++i) {
+      args.push_back(argv[i]);
+   }
+   props->parseCommandLineOptions(LoggingServerI::LoggingPropertyPrefix, args);
+   return props;
+}
 }
 
 bool LoggingServerDaemon::start(int argc, char *argv[], int &status)
 {
+   Ice::PropertiesPtr props = parseCommandLine(argc, argv);
+
    Ice::ObjectAdapterPtr adapter =
          communicator()->createObjectAdapterWithEndpoints("LoggingServer",
                                                           "default -p 10000");
-   adapter->add(new LoggingServerI,
-                communicator()->stringToIdentity("LoggingServer"));
+
+   IceUtil::Handle<LoggingServerI> server = new LoggingServerI;
+
+   server->configure(props);
+
+   adapter->add(server, communicator()->stringToIdentity("LoggingServer"));
    adapter->activate();
    status = EXIT_SUCCESS;
    return true;

commit 4be820fc4c7fddd81ffdaefab81ea03877ef00f5
Author: David M. Lee <dlee at digium.com>
Date:   Tue Sep 21 14:45:08 2010 -0500

    Added Level parsing.

diff --git a/common/Level.h b/common/Level.h
index 855d95c..fac9add 100644
--- a/common/Level.h
+++ b/common/Level.h
@@ -48,6 +48,48 @@ inline std::ostream &operator<<(std::ostream &o, Level level)
    return o << "Unknown(" << level << ")";
 }
 
+inline Level parseString(std::string const &str)
+{
+   if (str == "Debug")
+   {
+      return Debug;
+   }
+   if (str == "Info")
+   {
+      return Info;
+   }
+   if (str == "Notice")
+   {
+      return Notice;
+   }
+   if (str == "Warning")
+   {
+      return Warning;
+   }
+   if (str == "Error")
+   {
+      return Error;
+   }
+   if (str == "Critical")
+   {
+      return Critical;
+   }
+   if (str == "Alert")
+   {
+      return Alert;
+   }
+   if (str == "Emergency")
+   {
+      return Emergency;
+   }
+   if (str == "Off")
+   {
+      return Off;
+   }
+   std::cerr << "Unknown level " << str << '\n';
+   return Off;
+}
+
 } // Logging
 } // System
 } // AsteriskSCF

commit 76e343e48694b406f64c265c9b15b873b0b255aa
Author: David M. Lee <dlee at digium.com>
Date:   Tue Sep 21 13:29:41 2010 -0500

    Made LoggingServer::logs a const function

diff --git a/ice/log4scf.ice b/ice/log4scf.ice
index a504a87..6a2ffc5 100644
--- a/ice/log4scf.ice
+++ b/ice/log4scf.ice
@@ -66,6 +66,7 @@ module Logging
        * server configuration may filter this message at the destination.
        * log may be a #define, hence the name logm.
        */
+      ["cpp:const"]
       idempotent void logs(string source, Level logLevel, string message);
    };
 
diff --git a/server/src/LoggingServer.cpp b/server/src/LoggingServer.cpp
index 3f2813e..0cd59ae 100644
--- a/server/src/LoggingServer.cpp
+++ b/server/src/LoggingServer.cpp
@@ -72,7 +72,7 @@ void LoggingServerI::setLevel(std::string const &source, Level level)
 }
 
 void LoggingServerI::logs(std::string const &source, Level level,
-                          const std::string &message, const Ice::Current&)
+                          const std::string &message, const Ice::Current&) const
 {
 
    if (isEnabledFor(source, level))
diff --git a/server/src/LoggingServer.h b/server/src/LoggingServer.h
index 5c51bc5..babd0b9 100644
--- a/server/src/LoggingServer.h
+++ b/server/src/LoggingServer.h
@@ -58,7 +58,7 @@ public:
    }
 
    void logs(std::string const &, Level, const std::string&,
-             const Ice::Current&);
+             const Ice::Current&) const;
 
    bool isEnabledFor(std::string const &source, Level level) const
    {

commit 16fa7b5a2e3152078fec3835c24a161a40eb66de
Author: David M. Lee <dlee at digium.com>
Date:   Tue Sep 21 13:29:06 2010 -0500

    Changed server to use Ice::Service.

diff --git a/server/src/main.cpp b/server/src/main.cpp
index 2de485f..2093d1e 100644
--- a/server/src/main.cpp
+++ b/server/src/main.cpp
@@ -6,48 +6,34 @@
  * All rights reserved.
  */
 
-#include <Ice/Ice.h>
+#include <Ice/Service.h>
 
 #include "LoggingServer.h"
 
 using namespace AsteriskSCF::System::Logging;
 
+namespace
+{
+class LoggingServerDaemon : public Ice::Service
+{
+   bool start(int argc, char *argv[], int &status);
+};
+}
+
+bool LoggingServerDaemon::start(int argc, char *argv[], int &status)
+{
+   Ice::ObjectAdapterPtr adapter =
+         communicator()->createObjectAdapterWithEndpoints("LoggingServer",
+                                                          "default -p 10000");
+   adapter->add(new LoggingServerI,
+                communicator()->stringToIdentity("LoggingServer"));
+   adapter->activate();
+   status = EXIT_SUCCESS;
+   return true;
+}
+
 int main(int argc, char *argv[])
 {
-   int status = 0;
-   Ice::CommunicatorPtr ic;
-   try
-   {
-      ic = Ice::initialize(argc, argv);
-      Ice::ObjectAdapterPtr adapter =
-               ic->createObjectAdapterWithEndpoints("LoggingServer",
-                                                    "default -p 10000");
-      Ice::ObjectPtr object = new LoggingServerI;
-      adapter->add(object, ic->stringToIdentity("LoggingServer"));
-      adapter->activate();
-      ic->waitForShutdown();
-   }
-   catch (const Ice::Exception& e)
-   {
-      std::cerr << e << '\n';
-      status = 1;
-   }
-   catch (const char* msg)
-   {
-      std::cerr << msg << '\n';
-      status = 1;
-   }
-   if (ic)
-   {
-      try
-      {
-         ic->destroy();
-      }
-      catch (const Ice::Exception& e)
-      {
-         std::cerr << e << '\n';
-         status = 1;
-      }
-   }
-   return status;
+   LoggingServerDaemon daemon;
+   return daemon.main(argc, argv);
 }

commit acef07b98be1c13aa38468c8f6ab2c75d7dbda4f
Author: David M. Lee <dlee at digium.com>
Date:   Tue Sep 21 16:47:30 2010 -0500

    logger.cpp -> Logger.cpp

diff --git a/client/src/logger.cpp b/client/src/Logger.cpp
similarity index 100%
rename from client/src/logger.cpp
rename to client/src/Logger.cpp

commit d2664e0bdb7985954b770e65de7862e32e5e5470
Author: David M. Lee <dlee at digium.com>
Date:   Tue Sep 21 10:46:08 2010 -0500

    Removing Ruby cruft.

diff --git a/log-client.rb b/log-client.rb
deleted file mode 100644
index e652f3c..0000000
--- a/log-client.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-# -*- coding: utf-8 -*-
-require 'log4scf.rb'
-
-status = 0
-ic = nil
-begin
-    ic = Ice::initialize(ARGV)
-    base = ic.stringToProxy("LoggingServer:tcp -h localhost ‑p 10000")
-    logger = AsteriskSCF::System::Logging::checkedCast(base)
-    if not logger
-        raise "Invalid proxy"
-    end
-
-    logger.log("component", -1, "Hello, log4scf")
-#rescue
-#    puts $!
-#    puts $!.backtrace.join("\n")
-#    status = 1
-end
-
-if ic
-    # Clean up
-    begin
-        ic.destroy()
-    rescue
-        puts $!
-        puts $!.backtrace.join("\n")
-        status = 1
-    end
-end
-
-exit(status)
diff --git a/log4scf.rb b/log4scf.rb
deleted file mode 100644
index 3770d8e..0000000
--- a/log4scf.rb
+++ /dev/null
@@ -1,297 +0,0 @@
-# **********************************************************************
-#
-# Copyright (c) 2003-2010 ZeroC, Inc. All rights reserved.
-#
-# This copy of Ice is licensed to you under the terms described in the
-# ICE_LICENSE file included in this distribution.
-#
-# **********************************************************************
-
-# Ice version 3.4.1
-
-# <auto-generated>
-#
-# Generated from file `log4scf.ice'
-#
-# Warning: do not edit this file.
-#
-# </auto-generated>
-
-require 'Ice'
-
-module AsteriskSCF
-
-    module System
-
-        module Logging
-
-            module V1
-
-                Version = "V1.0"
-
-                if not defined?(::AsteriskSCF::System::Logging::V1::Level)
-                    class Level
-                        include Comparable
-
-                        def initialize(val)
-                            fail("invalid value #{val} for Level") unless(val >= 0 and val < 9)
-                            @val = val
-                        end
-
-                        def Level.from_int(val)
-                            raise IndexError, "#{val} is out of range 0..8" if(val < 0 || val > 8)
-                            @@_values[val]
-                        end
-
-                        def to_s
-                            @@_names[@val]
-                        end
-
-                        def to_i
-                            @val
-                        end
-
-                        def <=>(other)
-                            other.is_a?(Level) or raise ArgumentError, "value must be a Level"
-                            @val <=> other.to_i
-                        end
-
-                        def hash
-                            @val.hash
-                        end
-
-                        def inspect
-                            @@_names[@val] + "(#{@val})"
-                        end
-
-                        def Level.each(&block)
-                            @@_values.each(&block)
-                        end
-
-                        @@_names = ['Debug', 'Info', 'Notice', 'Warning', 'Error', 'Critical', 'Alert', 'Emergency', 'Off']
-                        @@_values = [Level.new(0), Level.new(1), Level.new(2), Level.new(3), Level.new(4), Level.new(5), Level.new(6), Level.new(7), Level.new(8)]
-
-                        Debug = @@_values[0]
-                        Info = @@_values[1]
-                        Notice = @@_values[2]
-                        Warning = @@_values[3]
-                        Error = @@_values[4]
-                        Critical = @@_values[5]
-                        Alert = @@_values[6]
-                        Emergency = @@_values[7]
-                        Off = @@_values[8]
-
-                        private_class_method :new
-                    end
-
-                    T_Level = ::Ice::__defineEnum('::AsteriskSCF::System::Logging::V1::Level', Level, [Level::Debug, Level::Info, Level::Notice, Level::Warning, Level::Error, Level::Critical, Level::Alert, Level::Emergency, Level::Off])
-                end
-
-                if not defined?(::AsteriskSCF::System::Logging::V1::SourceSetting)
-                    class SourceSetting
-                        def initialize(source='', logLevel=::AsteriskSCF::System::Logging::V1::Level::Debug)
-                            @source = source
-                            @logLevel = logLevel
-                        end
-
-                        def hash
-                            _h = 0
-                            _h = 5 * _h + @source.hash
-                            _h = 5 * _h + @logLevel.hash
-                            _h % 0x7fffffff
-                        end
-
-                        def ==(other)
-                            return false if
-                                @source != other.source or
-                                @logLevel != other.logLevel
-                            true
-                        end
-
-                        def eql?(other)
-                            return other.class == self.class && other == self
-                        end
-
-                        def inspect
-                            ::Ice::__stringify(self, T_SourceSetting)
-                        end
-
-                        attr_accessor :source, :logLevel
-                    end
-
-                    T_SourceSetting = ::Ice::__defineStruct('::AsteriskSCF::System::Logging::V1::SourceSetting', SourceSetting, [
-                        ["source", ::Ice::T_string],
-                        ["logLevel", ::AsteriskSCF::System::Logging::V1::T_Level]
-                    ])
-                end
-
-                if not defined?(::AsteriskSCF::System::Logging::V1::T_SourceSettingSeq)
-                    T_SourceSettingSeq = ::Ice::__defineSequence('::AsteriskSCF::System::Logging::V1::SourceSettingSeq', ::AsteriskSCF::System::Logging::V1::T_SourceSetting)
-                end
-
-                if not defined?(::AsteriskSCF::System::Logging::V1::Configuration)
-                    class Configuration
-                        def initialize(sourceSettings=nil)
-                            @sourceSettings = sourceSettings
-                        end
-
-                        def hash
-                            _h = 0
-                            _h = 5 * _h + @sourceSettings.hash
-                            _h % 0x7fffffff
-                        end
-
-                        def ==(other)
-                            return false if
-                                @sourceSettings != other.sourceSettings
-                            true
-                        end
-
-                        def eql?(other)
-                            return other.class == self.class && other == self
-                        end
-
-                        def inspect
-                            ::Ice::__stringify(self, T_Configuration)
-                        end
-
-                        attr_accessor :sourceSettings
-                    end
-
-                    T_Configuration = ::Ice::__defineStruct('::AsteriskSCF::System::Logging::V1::Configuration', Configuration, [["sourceSettings", ::AsteriskSCF::System::Logging::V1::T_SourceSettingSeq]])
-                end
-
-                if not defined?(::AsteriskSCF::System::Logging::V1::T_LoggingClient)
-                    T_LoggingClient = ::Ice::__declareClass('::AsteriskSCF::System::Logging::V1::LoggingClient')
-                    T_LoggingClientPrx = ::Ice::__declareProxy('::AsteriskSCF::System::Logging::V1::LoggingClient')
-                end
-
-                if not defined?(::AsteriskSCF::System::Logging::V1::LoggingServer_mixin)
-                    module LoggingServer_mixin
-                        include ::Ice::Object_mixin
-
-                        def ice_ids(current=nil)
-                            ['::AsteriskSCF::System::Logging::V1::LoggingServer', '::Ice::Object']
-                        end
-
-                        def ice_id(current=nil)
-                            '::AsteriskSCF::System::Logging::V1::LoggingServer'
-                        end
-
-                        #
-                        # Operation signatures.
-                        #
-                        # def log(source, logLevel, message, current=nil)
-                        # def registerClient(client, current=nil)
-
-                        def inspect
-                            ::Ice::__stringify(self, T_LoggingServer)
-                        end
-                    end
-                    class LoggingServer
-                        include LoggingServer_mixin
-                        
-                        def LoggingServer.ice_staticId()
-                            '::AsteriskSCF::System::Logging::V1::LoggingServer'
-                        end
-                    end
-                    module LoggingServerPrx_mixin
-
-                        def log(source, logLevel, message, _ctx=nil)
-                            LoggingServer_mixin::OP_log.invoke(self, [source, logLevel, message], _ctx)
-                        end
-
-                        def registerClient(client, _ctx=nil)
-                            LoggingServer_mixin::OP_registerClient.invoke(self, [client], _ctx)
-                        end
-                    end
-                    class LoggingServerPrx < ::Ice::ObjectPrx
-                        include LoggingServerPrx_mixin
-
-                        def LoggingServerPrx.checkedCast(proxy, facetOrCtx=nil, _ctx=nil)
-                            ice_checkedCast(proxy, '::AsteriskSCF::System::Logging::V1::LoggingServer', facetOrCtx, _ctx)
-                        end
-
-                        def LoggingServerPrx.uncheckedCast(proxy, facet=nil)
-                            ice_uncheckedCast(proxy, facet)
-                        end
-                    end
-
-                    if not defined?(::AsteriskSCF::System::Logging::V1::T_LoggingServer)
-                        T_LoggingServer = ::Ice::__declareClass('::AsteriskSCF::System::Logging::V1::LoggingServer')
-                        T_LoggingServerPrx = ::Ice::__declareProxy('::AsteriskSCF::System::Logging::V1::LoggingServer')
-                    end
-
-                    T_LoggingServer.defineClass(LoggingServer, true, nil, [], [])
-                    LoggingServer_mixin::ICE_TYPE = T_LoggingServer
-
-                    T_LoggingServerPrx.defineProxy(LoggingServerPrx, T_LoggingServer)
-                    LoggingServerPrx::ICE_TYPE = T_LoggingServerPrx
-
-                    LoggingServer_mixin::OP_log = ::Ice::__defineOperation('log', ::Ice::OperationMode::Idempotent, ::Ice::OperationMode::Idempotent, false, [::Ice::T_string, ::AsteriskSCF::System::Logging::V1::T_Level, ::Ice::T_string], [], nil, [])
-                    LoggingServer_mixin::OP_registerClient = ::Ice::__defineOperation('registerClient', ::Ice::OperationMode::Normal, ::Ice::OperationMode::Normal, false, [::AsteriskSCF::System::Logging::V1::T_LoggingClientPrx], [], nil, [])
-                end
-
-                if not defined?(::AsteriskSCF::System::Logging::V1::LoggingClient_mixin)
-                    module LoggingClient_mixin
-                        include ::Ice::Object_mixin
-
-                        def ice_ids(current=nil)
-                            ['::AsteriskSCF::System::Logging::V1::LoggingClient', '::Ice::Object']
-                        end
-
-                        def ice_id(current=nil)
-                            '::AsteriskSCF::System::Logging::V1::LoggingClient'
-                        end
-
-                        #
-                        # Operation signatures.
-                        #
-                        # def configured(server, logConfiguration, current=nil)
-
-                        def inspect
-                            ::Ice::__stringify(self, T_LoggingClient)
-                        end
-                    end
-                    class LoggingClient
-                        include LoggingClient_mixin
-                        
-                        def LoggingClient.ice_staticId()
-                            '::AsteriskSCF::System::Logging::V1::LoggingClient'
-                        end
-                    end
-                    module LoggingClientPrx_mixin
-
-                        def configured(server, logConfiguration, _ctx=nil)
-                            LoggingClient_mixin::OP_configured.invoke(self, [server, logConfiguration], _ctx)
-                        end
-                    end
-                    class LoggingClientPrx < ::Ice::ObjectPrx
-                        include LoggingClientPrx_mixin
-
-                        def LoggingClientPrx.checkedCast(proxy, facetOrCtx=nil, _ctx=nil)
-                            ice_checkedCast(proxy, '::AsteriskSCF::System::Logging::V1::LoggingClient', facetOrCtx, _ctx)
-                        end
-
-                        def LoggingClientPrx.uncheckedCast(proxy, facet=nil)
-                            ice_uncheckedCast(proxy, facet)
-                        end
-                    end
-
-                    if not defined?(::AsteriskSCF::System::Logging::V1::T_LoggingClient)
-                        T_LoggingClient = ::Ice::__declareClass('::AsteriskSCF::System::Logging::V1::LoggingClient')
-                        T_LoggingClientPrx = ::Ice::__declareProxy('::AsteriskSCF::System::Logging::V1::LoggingClient')
-                    end
-
-                    T_LoggingClient.defineClass(LoggingClient, true, nil, [], [])
-                    LoggingClient_mixin::ICE_TYPE = T_LoggingClient
-
-                    T_LoggingClientPrx.defineProxy(LoggingClientPrx, T_LoggingClient)
-                    LoggingClientPrx::ICE_TYPE = T_LoggingClientPrx
-
-                    LoggingClient_mixin::OP_configured = ::Ice::__defineOperation('configured', ::Ice::OperationMode::Normal, ::Ice::OperationMode::Normal, false, [::AsteriskSCF::System::Logging::V1::T_LoggingServerPrx, ::AsteriskSCF::System::Logging::V1::T_Configuration], [], nil, [])
-                end
-            end
-        end
-    end
-end

commit 22ba76dc61fae7f6f30c8cf66471f96ac05ddd60
Author: David M. Lee <dlee at digium.com>
Date:   Tue Sep 21 10:43:59 2010 -0500

    Oops.  Wrong version of cmake repo.

diff --git a/cmake b/cmake
index 4f2c4db..9615ced 160000
--- a/cmake
+++ b/cmake
@@ -1 +1 @@
-Subproject commit 4f2c4db13921b9af66b4b34a435c72c490d7aaaa
+Subproject commit 9615ced9f07f8c01ca1c8b3f2b29aa5d05a185da

commit 53d97ac8fa9b68aafeb73ca5dc8bbbd2bdeb5d74
Author: David M. Lee <dlee at digium.com>
Date:   Tue Sep 21 10:40:23 2010 -0500

    Comments

diff --git a/client/src/logger.h b/client/src/logger.h
index 0df0750..b03dbb7 100644
--- a/client/src/logger.h
+++ b/client/src/logger.h
@@ -100,6 +100,9 @@ public:
       inheritedLevel = true;
    }
 
+   /**
+    * Returns the effective level of this Logger.
+    */
    Level getEffectiveLevel() const
    {
       if (inheritedLevel == true && parent != 0)

commit 7eeaa53a4b462d9089fe9767d552a7d46bb33136
Author: David M. Lee <dlee at digium.com>
Date:   Tue Sep 21 09:39:24 2010 -0500

    Removed getLevel() from Logger.  Could be confusing.

diff --git a/client/src/logger.h b/client/src/logger.h
index b54c4e5..0df0750 100644
--- a/client/src/logger.h
+++ b/client/src/logger.h
@@ -100,11 +100,6 @@ public:
       inheritedLevel = true;
    }
 
-   Level getLevel() const
-   {
-      return logLevel;
-   }
-
    Level getEffectiveLevel() const
    {
       if (inheritedLevel == true && parent != 0)
@@ -113,7 +108,7 @@ public:
       }
       else
       {
-         return getLevel();
+         return logLevel;
       }
    }
 

commit 36e5db995d663d9d6f68cedcf9cd8a6b17c5e628
Author: David M. Lee <dlee at digium.com>
Date:   Tue Sep 21 09:14:27 2010 -0500

    Added singleton for LoggerFactory.  Made Level/ostream stuff common for client and server.  Got rid of SourceNode on client.

diff --git a/client/src/CMakeLists.txt b/client/src/CMakeLists.txt
index fc5964a..18ee4f1 100644
--- a/client/src/CMakeLists.txt
+++ b/client/src/CMakeLists.txt
@@ -8,6 +8,8 @@
 
 hydra_component_init(logging-client CXX)
 
+include_directories(../../common)
+
 hydra_component_add_file(logging-client Logger.cpp)
 hydra_component_add_file(logging-client LoggerFactory.cpp)
 hydra_component_add_file(logging-client IceLogger.cpp)
diff --git a/client/src/IceLogger.cpp b/client/src/IceLogger.cpp
index bcfceb4..a669ad7 100644
--- a/client/src/IceLogger.cpp
+++ b/client/src/IceLogger.cpp
@@ -33,7 +33,7 @@ private:
 
 }
 
-std::auto_ptr<LogOut> buildIceLogger(LoggingServerPrx const &server)
+std::auto_ptr<LogOut> AsteriskSCF::System::Logging::buildIceLogger(LoggingServerPrx const &server)
 {
    return std::auto_ptr<LogOut>(new IceLogger(server));
 }
diff --git a/client/src/LoggerFactory.cpp b/client/src/LoggerFactory.cpp
index 826d26b..5ea4689 100644
--- a/client/src/LoggerFactory.cpp
+++ b/client/src/LoggerFactory.cpp
@@ -21,19 +21,6 @@
 using namespace AsteriskSCF::System::Logging;
 using namespace boost::algorithm;
 
-SourceNode &SourceNode::getChild(std::string const &name)
-{
-   // ref to ptr allows us to update the map in-place
-   SourceNode *&child = children[name];
-   if (child == 0)
-   {
-      std::string childName = logger.getName().empty() ? name
-         : logger.getName() + "." + name;
-      child = new SourceNode(childName, logger);
-   }
-   return *child;
-}
-
 LoggerFactory::LoggerFactory(LogOut &out) :
    out(out), root("", out)
 {
@@ -44,11 +31,18 @@ Logger &LoggerFactory::getLogger(std::string const &source)
    std::vector<std::string> path;
    split(path, source, std::bind1st(std::equal_to<char>(), '.'));
 
-   SourceNode *node = &root;
+   Logger *logger = &root;
    for (std::vector<std::string>::iterator i = path.begin(); i != path.end(); ++i)
    {
-      node = &node->getChild(*i);
+      logger = &logger->getChild(*i);
... 3983 lines suppressed ...


-- 
asterisk-scf/integration/logger.git



More information about the asterisk-scf-commits mailing list