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

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Tue Sep 21 17:03:40 CDT 2010


branch "master" has been updated
       via  ad4240ebad303c6089d8d5ef3376b16027cd9dc7 (commit)
       via  8c39120b4fd70063a64242748d5957ee08899f71 (commit)
       via  1bef67a454a6434fee76809f1409e85491f71b3c (commit)
       via  4b4661d7922d7dda17e696006482e902c2c0a401 (commit)
       via  4677228d94e2eca4cf7a6dece7b3609bb9732941 (commit)
       via  b5578075c8a975bc16f876a733157fc1e2192f7e (commit)
       via  dcdb57a2132a825372a1d75243e05b1962c3b4b3 (commit)
       via  6a804e279ef053bf9d31034ce53d1957e80f793a (commit)
       via  4be820fc4c7fddd81ffdaefab81ea03877ef00f5 (commit)
       via  76e343e48694b406f64c265c9b15b873b0b255aa (commit)
       via  16fa7b5a2e3152078fec3835c24a161a40eb66de (commit)
      from  acef07b98be1c13aa38468c8f6ab2c75d7dbda4f (commit)

Summary of changes:
 client/src/IceLogger.cpp     |    3 +-
 client/src/Logger.cpp        |   37 +++++++++++++++++-
 client/src/logger.h          |   78 ++++++++++++++++++-------------------
 client/test/scf-log.cpp      |   88 +++++++++++++++++++++++++++++++----------
 common/Level.h               |   42 ++++++++++++++++++++
 ice/log4scf.ice              |    1 +
 server/src/LoggingServer.cpp |   58 +++++++++++++++++++++++++--
 server/src/LoggingServer.h   |   15 +++++--
 server/src/main.cpp          |   80 ++++++++++++++++++++-----------------
 9 files changed, 290 insertions(+), 112 deletions(-)


- Log -----------------------------------------------------------------
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);
 }

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


-- 
asterisk-scf/integration/log4scf.git



More information about the asterisk-scf-commits mailing list