[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 10:59:46 CDT 2010


branch "master" has been updated
       via  640a139ba9fcb9edc57c1a4a983040e3071d7683 (commit)
       via  45fac2c09e8c27d65c54d6c2d267ddf2cdfea485 (commit)
       via  1217acc9b65cdb7522c9c4a4d8af71c1c84ea7d5 (commit)
      from  3024590b1233c89e3e769fb65d67b01e1fd04bec (commit)

Summary of changes:
 client/test/CMakeLists.txt |    1 +
 client/test/scf-log.cpp    |   65 +++++++++++++++++++++++++-------------------
 2 files changed, 38 insertions(+), 28 deletions(-)


- Log -----------------------------------------------------------------
commit 640a139ba9fcb9edc57c1a4a983040e3071d7683
Author: David M. Lee <dlee at digium.com>
Date:   Wed Sep 29 10:57:04 2010 -0500

    Switched from getopt to boost::program_options for Windows compat.

diff --git a/client/test/CMakeLists.txt b/client/test/CMakeLists.txt
index b4c198b..991380f 100644
--- a/client/test/CMakeLists.txt
+++ b/client/test/CMakeLists.txt
@@ -31,6 +31,7 @@ hydra_component_init(scf-log CXX)
 
 hydra_component_add_file(scf-log scf-log.cpp)
 hydra_component_add_slice(scf-log LoggerIf)
+hydra_component_add_boost_libraries(scf-log program_options)
 
 hydra_component_build_standalone(scf-log)
 target_link_libraries(scf-log logging-client)
diff --git a/client/test/scf-log.cpp b/client/test/scf-log.cpp
index 9138a7a..481b8de 100644
--- a/client/test/scf-log.cpp
+++ b/client/test/scf-log.cpp
@@ -7,12 +7,18 @@
  */
 
 #include <Ice/Ice.h>
-//#include <unistd.h>
+
+#include <boost/program_options/option.hpp>
+#include <boost/program_options/options_description.hpp>
+#include <boost/program_options/positional_options.hpp>
+#include <boost/program_options/variables_map.hpp>
+#include <boost/program_options/parsers.hpp>
 
 #include "IceLogger.h"
 #include "logger.h"
 
 using namespace AsteriskSCF::System::Logging;
+namespace po = boost::program_options;
 
 const std::string DefaultName = "AsteriskSCF.System.Logger";
 const Level DefaultLevel = Info;
@@ -41,40 +47,42 @@ int ScfLogClientApplication::run(int argc, char *argv[])
    Level level = DefaultLevel;
    std::string message = DefaultMessage;
 
-   int ch;
-   while ((ch = getopt(argc, argv, "p:t:")) != -1)
+   po::options_description desc("Allowed options");
+   desc.add_options()
+      ("help,?", "produce this message")
+      ("priority,p", po::value<std::string>(), "Message priority")
+      ("tag,t", po::value<std::string>(), "Message tag")
+      ("message", po::value<std::string>(), "message");
+   po::positional_options_description pd;
+   pd.add("message", 1);
+
+   po::variables_map vm;
+   po::basic_command_line_parser<char> parser(argc, argv);
+   parser.options(desc);
+   parser.positional(pd);
+   po::store(parser.run(), vm);
+   po::notify(vm);
+
+   if (vm.count("help"))
+   {
+      usage(std::cout);
+      std::cout << '\n' << desc << '\n';
+      return EXIT_SUCCESS;
+   }
+
+   if (vm.count("priority"))
    {
-      switch (ch)
-      {
-      case 'p':
-         level = parseString(optarg);
-         break;
-      case 't':
-         name = std::string(optarg);
-         break;
-      case '?':
-         usage(std::cout);
-         return EXIT_SUCCESS;
-      default:
-         usage(std::clog);
-         return EXIT_FAILURE;
-      }
+      level = parseString(vm["priority"].as<std::string> ());
    }
-   argc -= optind;
-   argv += optind;
 
-   if (argc > 0)
+   if (vm.count("tag"))
    {
-      message = std::string(argv[0]);
-      ++argv;
-      --argv;
+      name = vm["tag"].as<std::string> ();
    }
 
-   // in case we have a multi-word message
-   while (argc-- > 0)
+   if (vm.count("message"))
    {
-      message += " " + std::string(argv[0]);
-      ++argv;
+      message = vm["message"].as<std::string> ();
    }
 
    setupDefaultProperties();

commit 45fac2c09e8c27d65c54d6c2d267ddf2cdfea485
Merge: 1217acc 3024590
Author: David M. Lee <dlee at digium.com>
Date:   Wed Sep 29 09:38:46 2010 -0500

    Merge branch 'master' of git.asterisk.org:asterisk-scf/integration/logger


commit 1217acc9b65cdb7522c9c4a4d8af71c1c84ea7d5
Author: David M. Lee <dlee at digium.com>
Date:   Mon Sep 27 14:26:35 2010 -0500

    scf-log should fail when it cannot log.

diff --git a/client/test/scf-log.cpp b/client/test/scf-log.cpp
index 672a87b..c62daad 100644
--- a/client/test/scf-log.cpp
+++ b/client/test/scf-log.cpp
@@ -90,6 +90,7 @@ int ScfLogClientApplication::run(int argc, char *argv[])
    else
    {
       std::clog << "Could not log.\n";
+      return EXIT_FAILURE;
    }
 
    return EXIT_SUCCESS;

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


-- 
asterisk-scf/integration/logger.git



More information about the asterisk-scf-commits mailing list