[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 Oct 6 08:31:57 CDT 2010
branch "master" has been updated
via a867306cbc5dce5b0cd899094b3215921f0263d3 (commit)
via 1764dab6cd86a9f51778db358490e4bed57e7f65 (commit)
from 0cc0c02a16e404b94d54c8cb6736dee14a671352 (commit)
Summary of changes:
.gitignore | 1 +
client/src/IceLogger.cpp | 68 +++++++++++++++++++++++++---------------------
client/src/IceLogger.h | 18 +++++++++++-
client/test/scf-log.cpp | 4 +++
4 files changed, 59 insertions(+), 32 deletions(-)
- Log -----------------------------------------------------------------
commit a867306cbc5dce5b0cd899094b3215921f0263d3
Author: David M. Lee <dlee at digium.com>
Date: Wed Oct 6 08:31:16 2010 -0500
Made IceLogger more robust. Now createIceLogger will never return null.
diff --git a/client/src/IceLogger.cpp b/client/src/IceLogger.cpp
index a6a8f30..e056eda 100644
--- a/client/src/IceLogger.cpp
+++ b/client/src/IceLogger.cpp
@@ -30,11 +30,11 @@ void IceLogger::logs(std::string const &name, Level logLevel,
}
catch (std::exception const &e)
{
- std::clog << "Error contacting server: " << e.what() << '\n';
+ std::clog << "Failed to contact LoggerServer: " << e.what() << '\n';
}
catch (...)
{
- std::clog << "Error contacting server";
+ std::clog << "Failed to contact LoggerServer";
}
if (!logged)
@@ -76,6 +76,11 @@ void ConfiguredIceLogger::updateLoggerFromServiceLocator()
// couldn't find the service;
mLogger.setServer(LoggingServerPrx());
}
+ catch (std::exception const &e)
+ {
+ std::clog << "Failed to locate LoggerService: " << e.what() << '\n';
+ mLogger.setServer(LoggingServerPrx());
+ }
}
}
@@ -140,48 +145,49 @@ ConfiguredIceLoggerPtr AsteriskSCF::System::Logging::createIceLogger(
}
catch (std::exception const &e)
{
- std::clog << "Failed to contact LoggerServer: ";
- std::clog << e.what() << '\n';
+ std::clog << "Failed to contact LoggerServer: " << e.what() << '\n';
}
- // then try the service locator.
- try
+ ServiceLocatorPrx locator = ServiceLocatorPrx::uncheckedCast(
+ communicator->propertyToProxy("LocatorService.Proxy"));
+ // if the LocatorService.Proxy isn't set, we'll log a message, but proceed
+ // on in ignorance. we'll basically build an IceLogger that can never
+ // log to a LoggerServer because it can never find it.
+ if (!locator)
{
- IceStorm::TopicManagerPrx topicManager =
- IceStorm::TopicManagerPrx::checkedCast(communicator->propertyToProxy(
- "TopicManager.Proxy"));
+ std::clog << "LocatorService.Proxy not set. Cannot find "
+ << LoggingServerGuid << '\n';
+ }
- ServiceLocatorPrx locator = ServiceLocatorPrx::checkedCast(
- communicator->propertyToProxy("LocatorService.Proxy"));
+ ConfiguredIceLoggerPtr logger = new ConfiguredIceLogger(locator);
+ logger->updateLoggerFromServiceLocator();
- if (locator)
+ IceStorm::TopicManagerPrx topicManager =
+ IceStorm::TopicManagerPrx::uncheckedCast(
+ communicator->propertyToProxy(
+ "TopicManager.Proxy"));
+ if (topicManager)
+ {
+ try
{
- ConfiguredIceLoggerPtr logger = new ConfiguredIceLogger(locator);
- // register with IceStorm for callbacks
- if (topicManager)
+ Ice::ObjectPrx proxy = adapter->addWithUUID(logger)->ice_oneway();
+ IceStorm::TopicPrx topic = topicManager->retrieve(Discovery::TOPIC);
+ if (topic)
{
- Ice::ObjectPrx proxy = adapter->addWithUUID(logger)->ice_oneway();
- IceStorm::TopicPrx topic = topicManager->retrieve(Discovery::TOPIC);
topic->subscribeAndGetPublisher(IceStorm::QoS(), proxy);
- adapter->activate();
- }
- else
- {
- std::clog << "IceStorm unavailable. Will not receive updates.\n";
}
- logger->updateLoggerFromServiceLocator();
-
- return logger;
+ }
+ catch (std::exception const &e)
+ {
+ std::clog << "Failed to subscribe to " << Discovery::TOPIC << ": "
+ << e.what() << '\n';
}
}
- catch (std::exception const &e)
+ else
{
- std::clog << "Failed to contact ServiceLocator: ";
- std::clog << e.what() << '\n';
+ std::clog << "TopicManager.Proxy not set. Will not receive updates.\n";
}
- std::clog << "Failed to construct Logger proxy.\n";
+ return logger;
- // couldn't find the proxy
- return ConfiguredIceLoggerPtr();
}
diff --git a/client/src/IceLogger.h b/client/src/IceLogger.h
index 63e4084..8bcf9c6 100644
--- a/client/src/IceLogger.h
+++ b/client/src/IceLogger.h
@@ -75,7 +75,23 @@ private:
typedef IceUtil::Handle<ConfiguredIceLogger> ConfiguredIceLoggerPtr;
-HYDRA_ICEBOX_EXPORT ConfiguredIceLoggerPtr createIceLogger(Ice::ObjectAdapterPtr adapter);
+/**
+ * Constructs an IceLogger, as specified in the properties of the
+ * given adapter's communicator's properties.
+ *
+ * <ul>
+ * <li>LoggerServer.Proxy - connect directly to LoggerServer; don't use
+ * LocatorService</li>
+ * <li>LocatorService.Proxy - proxy string for LocatorService</li>
+ * <li>TopicManager.Proxy - proxy string for TopicManager. Only used when
+ * using the LocatorService</li>
+ * </ul>
+ *
+ * @param adapter ObjectAdapter to use for listening to the Discovery topic.
+ * @return Smart pointer to a new ConfiguredIceLogger. Will never return null.
+ */
+HYDRA_ICEBOX_EXPORT ConfiguredIceLoggerPtr createIceLogger(
+ Ice::ObjectAdapterPtr adapter);
} // Logging
} // System
diff --git a/client/test/scf-log.cpp b/client/test/scf-log.cpp
index 481b8de..e892985 100644
--- a/client/test/scf-log.cpp
+++ b/client/test/scf-log.cpp
@@ -114,6 +114,10 @@ void ScfLogClientApplication::setupDefaultProperties()
Ice::PropertiesPtr props = communicator()->getProperties();
setDefaultProperty(*props, AdapterName + ".Endpoints", "default");
+ setDefaultProperty(*props, "LocatorService.Proxy",
+ "LocatorService:tcp -p 4411");
+ setDefaultProperty(*props, "TopicManager.Proxy",
+ "HydraIceStorm/TopicManager:default -p 10000");
}
void ScfLogClientApplication::setDefaultProperty(Ice::Properties &props,
commit 1764dab6cd86a9f51778db358490e4bed57e7f65
Author: David M. Lee <dlee at digium.com>
Date: Tue Oct 5 22:56:19 2010 -0500
.gitignore .log files.
diff --git a/.gitignore b/.gitignore
index 378eac2..801e565 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
build
+*.log
-----------------------------------------------------------------------
--
asterisk-scf/integration/logger.git
More information about the asterisk-scf-commits
mailing list