[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
Thu Oct 14 14:29:35 CDT 2010
branch "master" has been updated
via ba4a638028ee1ffe7de58862b23e30a740faffda (commit)
from 5761808cefdad97c8a77cdf7745ad10575868c98 (commit)
Summary of changes:
CMakeLists.txt | 20 +-
client/src/IceConfigurator.cpp | 154 +++++++-------
client/src/IceConfigurator.h | 16 +-
client/src/IceLogger.cpp | 272 +++++++++++-----------
client/src/IceLogger.h | 56 +++---
client/src/LogOut.cpp | 2 +-
client/src/LogOut.h | 6 +-
client/src/Logger.cpp | 176 ++++++++--------
client/src/LoggerFactory.cpp | 68 +++---
client/src/OstreamLogger.cpp | 22 +-
client/src/logger.h | 408 +++++++++++++++++-----------------
client/test/CMakeLists.txt | 2 +-
client/test/ExpectedLogOut.h | 34 ++--
client/test/IceConfigurator-test.cpp | 78 ++++----
client/test/LogBuf-test.cpp | 20 +-
client/test/Logger-test.cpp | 82 ++++----
client/test/LoggerFactory-test.cpp | 66 +++---
client/test/scf-log.cpp | 156 +++++++-------
common/Level.h | 120 +++++-----
server/src/ChainedLogOut.cpp | 52 +++---
server/src/ChainedLogOut.h | 60 +++---
server/src/FileChainedLogOut.cpp | 36 ++--
server/src/FileChainedLogOut.h | 36 ++--
server/src/LoggingServer.cpp | 218 +++++++++---------
server/src/LoggingServer.h | 96 ++++----
server/src/OstreamChainedLogOut.cpp | 6 +-
server/src/OstreamChainedLogOut.h | 24 +-
server/src/main.cpp | 220 +++++++++---------
server/test/LoggingServer-test.cpp | 86 ++++----
29 files changed, 1296 insertions(+), 1296 deletions(-)
- Log -----------------------------------------------------------------
commit ba4a638028ee1ffe7de58862b23e30a740faffda
Author: David M. Lee <dlee at digium.com>
Date: Thu Oct 14 14:28:53 2010 -0500
Style.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f8666a5..ca52922 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -10,20 +10,20 @@
if(NOT integrated_build STREQUAL "true")
- # Minimum we require is 2.6, any lower and stuff would fail horribly
- cmake_minimum_required(VERSION 2.6)
+ # Minimum we require is 2.6, any lower and stuff would fail horribly
+ cmake_minimum_required(VERSION 2.6)
- # Include common Hydra build infrastructure
- include(cmake/AsteriskSCF.cmake)
+ # Include common Hydra build infrastructure
+ include(cmake/AsteriskSCF.cmake)
- # This project is C++ based and requires a minimum of 3.4
- hydra_project("Logger" 3.4 CXX)
+ # This project is C++ based and requires a minimum of 3.4
+ hydra_project("Logger" 3.4 CXX)
- # Take care of slice definitions
- add_subdirectory(slice)
+ # Take care of slice definitions
+ add_subdirectory(slice)
else()
- set(logger_dir ${CMAKE_CURRENT_SOURCE_DIR} PARENT_SCOPE)
- set(logger_bindir ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE)
+ set(logger_dir ${CMAKE_CURRENT_SOURCE_DIR} PARENT_SCOPE)
+ set(logger_bindir ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE)
endif()
add_subdirectory(server)
diff --git a/client/src/IceConfigurator.cpp b/client/src/IceConfigurator.cpp
index 595d726..c158e27 100644
--- a/client/src/IceConfigurator.cpp
+++ b/client/src/IceConfigurator.cpp
@@ -23,102 +23,102 @@ namespace
*/
bool operator<(SourceConfiguration const &lhs, SourceConfiguration const &rhs)
{
- return lhs.name < rhs.name;
+ return lhs.name < rhs.name;
}
}
void IceConfigurator::configured(Configuration const &logConfiguration,
- Ice::Current const &)
+ Ice::Current const &)
{
- return configured(logConfiguration);
+ return configured(logConfiguration);
}
void IceConfigurator::configured(Configuration const &logConfiguration)
{
- std::vector<std::string> oldConfig = mFactory.getLoggerNames();
- SourceConfigurationSeq newConfig = logConfiguration.sourceSettings;
+ std::vector<std::string> oldConfig = mFactory.getLoggerNames();
+ SourceConfigurationSeq newConfig = logConfiguration.sourceSettings;
- // processing is easier if lists are sorted
- std::sort(oldConfig.begin(), oldConfig.end());
- std::sort(newConfig.begin(), newConfig.end());
+ // processing is easier if lists are sorted
+ std::sort(oldConfig.begin(), oldConfig.end());
+ std::sort(newConfig.begin(), newConfig.end());
- SourceConfigurationSeq::const_iterator newConfigIter =
- logConfiguration.sourceSettings.begin();
- std::vector<std::string>::const_iterator oldConfigIter = oldConfig.begin();
+ SourceConfigurationSeq::const_iterator newConfigIter =
+ logConfiguration.sourceSettings.begin();
+ std::vector<std::string>::const_iterator oldConfigIter = oldConfig.begin();
- while (newConfigIter != logConfiguration.sourceSettings.end()
- || oldConfigIter != oldConfig.end())
- {
- int cmp;
+ while (newConfigIter != logConfiguration.sourceSettings.end()
+ || oldConfigIter != oldConfig.end())
+ {
+ int cmp;
- if (newConfigIter == logConfiguration.sourceSettings.end())
- {
- // we ran out of new config; unset the rest of the old config
- // new[end] < old
- cmp = 1;
- }
- else if (oldConfigIter == oldConfig.end())
- {
- // we ran out of the old config; set rest of the new config
- // new > old[end]
- cmp = -1;
- }
- else
- {
- // compare the names
- cmp = newConfigIter->name.compare(*oldConfigIter);
- }
+ if (newConfigIter == logConfiguration.sourceSettings.end())
+ {
+ // we ran out of new config; unset the rest of the old config
+ // new[end] < old
+ cmp = 1;
+ }
+ else if (oldConfigIter == oldConfig.end())
+ {
+ // we ran out of the old config; set rest of the new config
+ // new > old[end]
+ cmp = -1;
+ }
+ else
+ {
+ // compare the names
+ cmp = newConfigIter->name.compare(*oldConfigIter);
+ }
- if (cmp < 0)
- {
- // apply a new config
- mFactory.getLogger(newConfigIter->name).setLevel(
- newConfigIter->logLevel);
- ++newConfigIter;
- }
- else if (cmp == 0)
- {
- // change an old config
- mFactory.getLogger(newConfigIter->name).setLevel(
- newConfigIter->logLevel);
- ++newConfigIter;
- ++oldConfigIter;
- }
- else // if (cmp > 0)
- {
- mFactory.getLogger(*oldConfigIter).unsetLevel();
- ++oldConfigIter;
- }
- }
+ if (cmp < 0)
+ {
+ // apply a new config
+ mFactory.getLogger(newConfigIter->name).setLevel(
+ newConfigIter->logLevel);
+ ++newConfigIter;
+ }
+ else if (cmp == 0)
+ {
+ // change an old config
+ mFactory.getLogger(newConfigIter->name).setLevel(
+ newConfigIter->logLevel);
+ ++newConfigIter;
+ ++oldConfigIter;
+ }
+ else // if (cmp > 0)
+ {
+ mFactory.getLogger(*oldConfigIter).unsetLevel();
+ ++oldConfigIter;
+ }
+ }
}
IceConfiguratorPtr AsteriskSCF::System::Logging::createIceConfigurator(
-Ice::ObjectAdapterPtr adapter, LoggerFactory &factory)
+ Ice::ObjectAdapterPtr adapter, LoggerFactory &factory)
{
-Ice::CommunicatorPtr communicator = adapter->getCommunicator();
+ Ice::CommunicatorPtr communicator = adapter->getCommunicator();
-try
-{
- IceStorm::TopicManagerPrx topicManager =
- IceStorm::TopicManagerPrx::checkedCast(communicator->propertyToProxy(
- "TopicManager.Proxy"));
+ try
+ {
+ IceStorm::TopicManagerPrx topicManager =
+ IceStorm::TopicManagerPrx::checkedCast(communicator->propertyToProxy(
+ "TopicManager.Proxy"));
- if (topicManager)
- {
- IceStorm::TopicPrx topic = topicManager->retrieve(
- ServerConfigurationTopic);
- IceConfiguratorPtr r = new IceConfigurator(factory);
- Ice::ObjectPrx proxy = adapter->addWithUUID(r)->ice_oneway();
- topic->subscribeAndGetPublisher(IceStorm::QoS(), proxy);
- adapter->activate();
- return r;
- }
-}
-catch (std::exception const &e)
-{
- std::clog << "Error registering with IceStorm: " << e.what() << '\n';
-}
+ if (topicManager)
+ {
+ IceStorm::TopicPrx topic = topicManager->retrieve(
+ ServerConfigurationTopic);
+ IceConfiguratorPtr r = new IceConfigurator(factory);
+ Ice::ObjectPrx proxy = adapter->addWithUUID(r)->ice_oneway();
+ topic->subscribeAndGetPublisher(IceStorm::QoS(), proxy);
+ adapter->activate();
+ return r;
+ }
+ }
+ catch (std::exception const &e)
+ {
+ std::clog << "Error registering with IceStorm: " << e.what() << '\n';
+ }
-std::clog << "IceStorm not available. Cannot listen to config events.\n";
-return IceConfiguratorPtr();
+ std::clog << "IceStorm not available. Cannot listen to config events.\n";
+ return IceConfiguratorPtr();
}
diff --git a/client/src/IceConfigurator.h b/client/src/IceConfigurator.h
index 267ea96..33cb3d3 100644
--- a/client/src/IceConfigurator.h
+++ b/client/src/IceConfigurator.h
@@ -24,21 +24,21 @@ namespace Logging
class IceConfigurator : public ServerConfigurationListener
{
public:
- IceConfigurator(LoggerFactory &factory) :
- mFactory(factory)
- {
- }
+ IceConfigurator(LoggerFactory &factory) :
+ mFactory(factory)
+ {
+ }
- HYDRA_ICEBOX_EXPORT void configured(Configuration const &logConfiguration, Ice::Current const &);
- HYDRA_ICEBOX_EXPORT void configured(Configuration const &logConfiguration);
+ HYDRA_ICEBOX_EXPORT void configured(Configuration const &logConfiguration, Ice::Current const &);
+ HYDRA_ICEBOX_EXPORT void configured(Configuration const &logConfiguration);
private:
- LoggerFactory &mFactory;
+ LoggerFactory &mFactory;
};
typedef IceUtil::Handle<IceConfigurator> IceConfiguratorPtr;
HYDRA_ICEBOX_EXPORT IceConfiguratorPtr createIceConfigurator(Ice::ObjectAdapterPtr adapter,
- LoggerFactory &factory);
+ LoggerFactory &factory);
} // Logging
} // System
diff --git a/client/src/IceLogger.cpp b/client/src/IceLogger.cpp
index e056eda..10f026c 100644
--- a/client/src/IceLogger.cpp
+++ b/client/src/IceLogger.cpp
@@ -17,177 +17,177 @@ using namespace AsteriskSCF::Core::Discovery::V1;
using namespace AsteriskSCF::System::Logging;
void IceLogger::logs(std::string const &name, Level logLevel,
- std::string const &message)
+ std::string const &message)
{
- bool logged = false;
- try
- {
- if (mServer)
- {
- mServer->logs(name, logLevel, message);
- logged = true;
- }
- }
- catch (std::exception const &e)
- {
- std::clog << "Failed to contact LoggerServer: " << e.what() << '\n';
- }
- catch (...)
- {
- std::clog << "Failed to contact LoggerServer";
- }
-
- if (!logged)
- {
- std::clog << "(no server) " << name << ":" << logLevel << ":" << message
- << '\n';
- }
+ bool logged = false;
+ try
+ {
+ if (mServer)
+ {
+ mServer->logs(name, logLevel, message);
+ logged = true;
+ }
+ }
+ catch (std::exception const &e)
+ {
+ std::clog << "Failed to contact LoggerServer: " << e.what() << '\n';
+ }
+ catch (...)
+ {
+ std::clog << "Failed to contact LoggerServer";
+ }
+
+ if (!logged)
+ {
+ std::clog << "(no server) " << name << ":" << logLevel << ":" << message
+ << '\n';
+ }
}
ConfiguredIceLogger::ConfiguredIceLogger(LoggingServerPrx server)
{
- mLogger.setServer(server);
+ mLogger.setServer(server);
}
ConfiguredIceLogger::ConfiguredIceLogger(ServiceLocatorPrx locator) :
- mLocator(locator)
+ mLocator(locator)
{
- //updateLoggerFromServiceLocator();
+ //updateLoggerFromServiceLocator();
}
void ConfiguredIceLogger::updateLoggerFromServiceLocator()
{
- if (mLocator)
- {
- try
- {
- ServiceLocatorParamsPtr loggingServerParams =
- new ServiceLocatorParams();
- Ice::ObjectPrx serverObject = mLocator->locate(loggingServerParams);
- if (serverObject)
- {
- LoggingServerPrx server = LoggingServerPrx::checkedCast(
- serverObject);
- mLogger.setServer(server);
- }
- }
- catch (Core::Discovery::V1::ServiceNotFound const &)
- {
- // 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());
- }
- }
+ if (mLocator)
+ {
+ try
+ {
+ ServiceLocatorParamsPtr loggingServerParams =
+ new ServiceLocatorParams();
+ Ice::ObjectPrx serverObject = mLocator->locate(loggingServerParams);
+ if (serverObject)
+ {
+ LoggingServerPrx server = LoggingServerPrx::checkedCast(
+ serverObject);
+ mLogger.setServer(server);
+ }
+ }
+ catch (Core::Discovery::V1::ServiceNotFound const &)
+ {
+ // 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());
+ }
+ }
}
void ConfiguredIceLogger::comparisonRegistered(std::string const &guid,
- Ice::Current const &)
+ Ice::Current const &)
{
- // no-op
+ // no-op
}
void ConfiguredIceLogger::comparisonUnregistered(std::string const &guid,
- Ice::Current const &)
+ Ice::Current const &)
{
- // no-op
+ // no-op
}
void ConfiguredIceLogger::serviceRegistered(std::string const &guid,
- Ice::Current const &)
+ Ice::Current const &)
{
- if (guid == LoggingServerGuid)
- {
- updateLoggerFromServiceLocator();
- }
+ if (guid == LoggingServerGuid)
+ {
+ updateLoggerFromServiceLocator();
+ }
}
void ConfiguredIceLogger::serviceUnregistered(std::string const &guid,
- Ice::Current const &)
+ Ice::Current const &)
{
- if (guid == LoggingServerGuid)
- {
- updateLoggerFromServiceLocator();
- }
+ if (guid == LoggingServerGuid)
+ {
+ updateLoggerFromServiceLocator();
+ }
}
void ConfiguredIceLogger::serviceSuspended(std::string const &guid,
- Ice::Current const &)
+ Ice::Current const &)
{
- if (guid == LoggingServerGuid)
- {
- updateLoggerFromServiceLocator();
- }
+ if (guid == LoggingServerGuid)
+ {
+ updateLoggerFromServiceLocator();
+ }
}
void ConfiguredIceLogger::serviceUnsuspended(std::string const &guid,
- Ice::Current const &)
+ Ice::Current const &)
{
- if (guid == LoggingServerGuid)
- {
- updateLoggerFromServiceLocator();
- }
+ if (guid == LoggingServerGuid)
+ {
+ updateLoggerFromServiceLocator();
+ }
}
ConfiguredIceLoggerPtr AsteriskSCF::System::Logging::createIceLogger(
- Ice::ObjectAdapterPtr adapter)
+ Ice::ObjectAdapterPtr adapter)
{
- Ice::CommunicatorPtr communicator = adapter->getCommunicator();
-
- // If directly specified, use that.
- try
- {
- Ice::ObjectPrx server = communicator->propertyToProxy(
- "LoggerServer.Proxy");
- if (server)
- {
- return ConfiguredIceLoggerPtr(new ConfiguredIceLogger(
- LoggingServerPrx::checkedCast(server)));
- }
- }
- catch (std::exception const &e)
- {
- std::clog << "Failed to contact LoggerServer: " << e.what() << '\n';
- }
-
- 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)
- {
- std::clog << "LocatorService.Proxy not set. Cannot find "
- << LoggingServerGuid << '\n';
- }
-
- ConfiguredIceLoggerPtr logger = new ConfiguredIceLogger(locator);
- logger->updateLoggerFromServiceLocator();
-
- IceStorm::TopicManagerPrx topicManager =
- IceStorm::TopicManagerPrx::uncheckedCast(
- communicator->propertyToProxy(
- "TopicManager.Proxy"));
- if (topicManager)
- {
- try
- {
- Ice::ObjectPrx proxy = adapter->addWithUUID(logger)->ice_oneway();
- IceStorm::TopicPrx topic = topicManager->retrieve(Discovery::TOPIC);
- if (topic)
- {
- topic->subscribeAndGetPublisher(IceStorm::QoS(), proxy);
- }
- }
- catch (std::exception const &e)
- {
- std::clog << "Failed to subscribe to " << Discovery::TOPIC << ": "
- << e.what() << '\n';
- }
- }
- else
- {
- std::clog << "TopicManager.Proxy not set. Will not receive updates.\n";
- }
-
- return logger;
+ Ice::CommunicatorPtr communicator = adapter->getCommunicator();
+
+ // If directly specified, use that.
+ try
+ {
+ Ice::ObjectPrx server = communicator->propertyToProxy(
+ "LoggerServer.Proxy");
+ if (server)
+ {
+ return ConfiguredIceLoggerPtr(new ConfiguredIceLogger(
+ LoggingServerPrx::checkedCast(server)));
+ }
+ }
+ catch (std::exception const &e)
+ {
+ std::clog << "Failed to contact LoggerServer: " << e.what() << '\n';
+ }
+
+ 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)
+ {
+ std::clog << "LocatorService.Proxy not set. Cannot find "
+ << LoggingServerGuid << '\n';
+ }
+
+ ConfiguredIceLoggerPtr logger = new ConfiguredIceLogger(locator);
+ logger->updateLoggerFromServiceLocator();
+
+ IceStorm::TopicManagerPrx topicManager =
+ IceStorm::TopicManagerPrx::uncheckedCast(
+ communicator->propertyToProxy(
+ "TopicManager.Proxy"));
+ if (topicManager)
+ {
+ try
+ {
+ Ice::ObjectPrx proxy = adapter->addWithUUID(logger)->ice_oneway();
+ IceStorm::TopicPrx topic = topicManager->retrieve(Discovery::TOPIC);
+ if (topic)
+ {
+ topic->subscribeAndGetPublisher(IceStorm::QoS(), proxy);
+ }
+ }
+ catch (std::exception const &e)
+ {
+ std::clog << "Failed to subscribe to " << Discovery::TOPIC << ": "
+ << e.what() << '\n';
+ }
+ }
+ else
+ {
+ std::clog << "TopicManager.Proxy not set. Will not receive updates.\n";
+ }
+
+ return logger;
}
diff --git a/client/src/IceLogger.h b/client/src/IceLogger.h
index 8bcf9c6..5a056a0 100644
--- a/client/src/IceLogger.h
+++ b/client/src/IceLogger.h
@@ -27,14 +27,14 @@ namespace Logging
class IceLogger : public LogOut
{
public:
- void logs(std::string const &name, Level logLevel,
- std::string const &message);
+ void logs(std::string const &name, Level logLevel,
+ std::string const &message);
- LoggingServerPrx getServer() const { return mServer; }
- void setServer(LoggingServerPrx server) { this->mServer = server; }
+ LoggingServerPrx getServer() const { return mServer; }
+ void setServer(LoggingServerPrx server) { this->mServer = server; }
private:
- LoggingServerPrx mServer;
+ LoggingServerPrx mServer;
};
/**
@@ -44,33 +44,33 @@ private:
class ConfiguredIceLogger : public Discovery::Events
{
public:
- /**
- * Configure an IceLogger directly with the LoggingServer.
- *
- * @param server Server proxy to log to.
- */
- ConfiguredIceLogger(LoggingServerPrx server);
- /**
- * Configure an IceLogger which gets LoggingServer from the ServiceLocator.
- *
- * @param locator Locator to use to get the LoggingServer proxy.
- */
- ConfiguredIceLogger(Core::Discovery::V1::ServiceLocatorPrx locator);
+ /**
+ * Configure an IceLogger directly with the LoggingServer.
+ *
+ * @param server Server proxy to log to.
+ */
+ ConfiguredIceLogger(LoggingServerPrx server);
+ /**
+ * Configure an IceLogger which gets LoggingServer from the ServiceLocator.
+ *
+ * @param locator Locator to use to get the LoggingServer proxy.
+ */
+ ConfiguredIceLogger(Core::Discovery::V1::ServiceLocatorPrx locator);
- LogOut &getLogger() { return mLogger; }
+ LogOut &getLogger() { return mLogger; }
- void updateLoggerFromServiceLocator();
+ void updateLoggerFromServiceLocator();
- void comparisonRegistered(std::string const &guid, Ice::Current const &);
- void comparisonUnregistered(std::string const &guid, Ice::Current const &);
- void serviceRegistered(std::string const &guid, Ice::Current const &);
- void serviceUnregistered(std::string const &guid, Ice::Current const &);
- void serviceSuspended(std::string const &guid, Ice::Current const &);
- void serviceUnsuspended(std::string const &guid, Ice::Current const &);
+ void comparisonRegistered(std::string const &guid, Ice::Current const &);
+ void comparisonUnregistered(std::string const &guid, Ice::Current const &);
+ void serviceRegistered(std::string const &guid, Ice::Current const &);
+ void serviceUnregistered(std::string const &guid, Ice::Current const &);
+ void serviceSuspended(std::string const &guid, Ice::Current const &);
+ void serviceUnsuspended(std::string const &guid, Ice::Current const &);
private:
- IceLogger mLogger;
- Core::Discovery::V1::ServiceLocatorPrx mLocator;
+ IceLogger mLogger;
+ Core::Discovery::V1::ServiceLocatorPrx mLocator;
};
typedef IceUtil::Handle<ConfiguredIceLogger> ConfiguredIceLoggerPtr;
@@ -91,7 +91,7 @@ typedef IceUtil::Handle<ConfiguredIceLogger> ConfiguredIceLoggerPtr;
* @return Smart pointer to a new ConfiguredIceLogger. Will never return null.
*/
HYDRA_ICEBOX_EXPORT ConfiguredIceLoggerPtr createIceLogger(
- Ice::ObjectAdapterPtr adapter);
+ Ice::ObjectAdapterPtr adapter);
} // Logging
} // System
diff --git a/client/src/LogOut.cpp b/client/src/LogOut.cpp
index 40c4484..078078c 100644
--- a/client/src/LogOut.cpp
+++ b/client/src/LogOut.cpp
@@ -12,5 +12,5 @@ using namespace AsteriskSCF::System::Logging;
LogOut::~LogOut()
{
- // no-op
+ // no-op
}
diff --git a/client/src/LogOut.h b/client/src/LogOut.h
index 8a75852..eca1f11 100755
--- a/client/src/LogOut.h
+++ b/client/src/LogOut.h
@@ -25,9 +25,9 @@ namespace Logging
class LogOut
{
public:
- HYDRA_ICEBOX_EXPORT virtual ~LogOut();
- HYDRA_ICEBOX_EXPORT virtual void logs(std::string const &name, Level logLevel,
- std::string const &message) = 0;
+ HYDRA_ICEBOX_EXPORT virtual ~LogOut();
+ HYDRA_ICEBOX_EXPORT virtual void logs(std::string const &name, Level logLevel,
+ std::string const &message) = 0;
};
diff --git a/client/src/Logger.cpp b/client/src/Logger.cpp
index 674bad1..7dd9c05 100644
--- a/client/src/Logger.cpp
+++ b/client/src/Logger.cpp
@@ -16,163 +16,163 @@ using namespace AsteriskSCF::System::Logging;
const int MESSAGE_SIZE = 120;
LogBuf::LogBuf(LogOut &out, std::string const &name, Level logLevel) :
- mOut(out), nName(name), mLogLevel(logLevel)
+ mOut(out), nName(name), mLogLevel(logLevel)
{
}
LogBuf::LogBuf(LogBuf const &orig) :
- mOut(orig.mOut), nName(orig.nName), mLogLevel(orig.mLogLevel)
+ mOut(orig.mOut), nName(orig.nName), mLogLevel(orig.mLogLevel)
{
- mBuffer.str(orig.mBuffer.str());
+ mBuffer.str(orig.mBuffer.str());
}
LogBuf::~LogBuf()
{
- if (!mBuffer.str().empty())
- {
- sendBuffer();
- }
+ if (!mBuffer.str().empty())
+ {
+ sendBuffer();
+ }
}
int LogBuf::overflow(int c)
{
- if (c == '\n' || c == traits_type::eof())
- {
- sendBuffer();
- return c;
- }
- return mBuffer.sputc(c);
+ if (c == '\n' || c == traits_type::eof())
+ {
+ sendBuffer();
+ return c;
+ }
+ return mBuffer.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 = mBuffer.str();
- mBuffer.str("");
- // send
- mOut.logs(nName, mLogLevel, message);
+ // 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 = mBuffer.str();
+ mBuffer.str("");
+ // send
+ mOut.logs(nName, mLogLevel, message);
}
Logger::Logger(std::string const &name, LogOut &out, Level logLevel) :
- mParent(0), mName(name), mOut(&out), mLogLevel(logLevel), mInheritedLevel(false)
+ mParent(0), mName(name), mOut(&out), mLogLevel(logLevel), mInheritedLevel(false)
{
}
Logger::Logger(Logger const &parent, std::string const &name) :
- mParent(&parent), mName(name), mOut(parent.mOut), mLogLevel(Off), mInheritedLevel(
- true)
+ mParent(&parent), mName(name), mOut(parent.mOut), mLogLevel(Off), mInheritedLevel(
+ true)
{
- // our name must begin w/ parent's name
- assert(name.find(parent.mName) == 0);
+ // our name must begin w/ parent's name
+ assert(name.find(parent.mName) == 0);
}
Logger::~Logger()
{
- IceUtil::Mutex::Lock childLock(mChildrenMutex);
- for (std::map<std::string, Logger *>::iterator i = mChildren.begin();
- i != mChildren.end();
- ++i)
- {
- delete i->second;
- i->second = 0;
- }
+ IceUtil::Mutex::Lock childLock(mChildrenMutex);
+ for (std::map<std::string, Logger *>::iterator i = mChildren.begin();
+ i != mChildren.end();
+ ++i)
+ {
+ delete i->second;
+ i->second = 0;
+ }
}
CondStream Logger::operator()(Level level) const
{
- return CondStream(*mOut, mName, level, isEnabledFor(level));
+ return CondStream(*mOut, mName, level, isEnabledFor(level));
}
void Logger::logs(Level level, std::string const &message) const
{
- if (isEnabledFor(level))
- {
- mOut->logs(mName, level, message);
- }
+ if (isEnabledFor(level))
+ {
+ mOut->logs(mName, level, message);
+ }
}
void Logger::logf(Level level, char const *fmt, ...) const
{
- va_list ap;
- va_start(ap, fmt);
- vlogf(level, fmt, ap);
- va_end(ap);
+ va_list ap;
+ va_start(ap, fmt);
+ vlogf(level, fmt, ap);
+ va_end(ap);
}
void Logger::vlogf(Level level, char const *fmt, va_list ap) const
{
- if (isEnabledFor(level))
- {
- char message[MESSAGE_SIZE];
- vsnprintf(message, sizeof(message), fmt, ap);
- // snprintf may not actually null terminate, so just in case
- message[MESSAGE_SIZE - 1] = '\0';
- mOut->logs(mName, level, message);
- }
+ if (isEnabledFor(level))
+ {
+ char message[MESSAGE_SIZE];
+ vsnprintf(message, sizeof(message), fmt, ap);
+ // snprintf may not actually null terminate, so just in case
+ message[MESSAGE_SIZE - 1] = '\0';
+ mOut->logs(mName, level, message);
+ }
}
void Logger::setOutput(LogOut &out)
{
- this->mOut = &out;
- IceUtil::Mutex::Lock childLock(mChildrenMutex);
- for (std::map<std::string, Logger *>::const_iterator i = mChildren.begin(); i
- != mChildren.end(); ++i)
- {
- i->second->setOutput(out);
- }
+ this->mOut = &out;
+ IceUtil::Mutex::Lock childLock(mChildrenMutex);
+ for (std::map<std::string, Logger *>::const_iterator i = mChildren.begin(); i
+ != mChildren.end(); ++i)
+ {
+ i->second->setOutput(out);
+ }
}
void Logger::setLevel(Level logLevel)
{
- this->mLogLevel = logLevel;
- mInheritedLevel = false;
+ this->mLogLevel = logLevel;
+ mInheritedLevel = false;
}
void Logger::unsetLevel()
{
- mInheritedLevel = true;
- mLogLevel = Off;
+ mInheritedLevel = true;
+ mLogLevel = Off;
}
Level Logger::getEffectiveLevel() const
{
- // if our level is unset, inherit level from our parent.
- if (mInheritedLevel == true && mParent != 0)
- {
- return mParent->getEffectiveLevel();
- }
- else
- {
- return mLogLevel;
- }
+ // if our level is unset, inherit level from our parent.
+ if (mInheritedLevel == true && mParent != 0)
+ {
+ return mParent->getEffectiveLevel();
+ }
+ else
+ {
+ return mLogLevel;
+ }
}
Logger &Logger::getChild(std::string const &childName)
{
- // ref to ptr allows us to update the map in-place
- IceUtil::Mutex::Lock childLock(mChildrenMutex);
- Logger *&child = mChildren[childName];
- if (child == 0)
- {
- std::string fullName = getName().empty() ? childName : getName() + "."
- + childName;
- child = new Logger(*this, fullName);
- }
- return *child;
+ // ref to ptr allows us to update the map in-place
+ IceUtil::Mutex::Lock childLock(mChildrenMutex);
+ Logger *&child = mChildren[childName];
+ if (child == 0)
+ {
+ std::string fullName = getName().empty() ? childName : getName() + "."
+ + childName;
+ child = new Logger(*this, fullName);
+ }
+ return *child;
}
std::vector<Logger const *> Logger::getChildren() const
{
- std::vector<Logger const *> r;
- IceUtil::Mutex::Lock childLock(mChildrenMutex);
- for (std::map<std::string, Logger *>::const_iterator i = mChildren.begin();
- i != mChildren.end();
- ++i)
- {
- r.push_back(i->second);
- }
- return r;
+ std::vector<Logger const *> r;
+ IceUtil::Mutex::Lock childLock(mChildrenMutex);
+ for (std::map<std::string, Logger *>::const_iterator i = mChildren.begin();
+ i != mChildren.end();
+ ++i)
+ {
+ r.push_back(i->second);
+ }
+ return r;
}
diff --git a/client/src/LoggerFactory.cpp b/client/src/LoggerFactory.cpp
index c14932b..883cd35 100644
--- a/client/src/LoggerFactory.cpp
+++ b/client/src/LoggerFactory.cpp
@@ -29,64 +29,64 @@ LoggerFactory *loggerFactory = 0;
void initLoggerFactory()
{
- static std::auto_ptr<LogOut> out = buildOstreamLogger(std::cout);
- static LoggerFactory singleton(*out);
- loggerFactory = &singleton;
+ static std::auto_ptr<LogOut> out = buildOstreamLogger(std::cout);
+ static LoggerFactory singleton(*out);
+ loggerFactory = &singleton;
}
}
LoggerFactory &AsteriskSCF::System::Logging::getLoggerFactory()
{
- boost::call_once(initLoggerFactory, oneFactory);
- return *loggerFactory;
+ boost::call_once(initLoggerFactory, oneFactory);
+ return *loggerFactory;
}
LoggerFactory::LoggerFactory(LogOut &out) :
- mRoot("", out)
+ mRoot("", out)
{
}
Logger &LoggerFactory::getLogger(std::string const &name)
{
- std::vector<std::string> path;
- // older versions of boost output a single entry when splitting an empty
- // string
- if (!name.empty())
- {
- split(path, name, std::bind1st(std::equal_to<char>(), '.'));
- }
-
- Logger *logger = &mRoot;
- for (std::vector<std::string>::iterator i = path.begin(); i != path.end(); ++i)
- {
- logger = &logger->getChild(*i);
- }
-
- return *logger;
+ std::vector<std::string> path;
+ // older versions of boost output a single entry when splitting an empty
+ // string
+ if (!name.empty())
+ {
+ split(path, name, std::bind1st(std::equal_to<char>(), '.'));
+ }
+
+ Logger *logger = &mRoot;
+ for (std::vector<std::string>::iterator i = path.begin(); i != path.end(); ++i)
+ {
+ logger = &logger->getChild(*i);
+ }
+
+ return *logger;
}
std::vector<std::string> LoggerFactory::getLoggerNames() const
{
- std::vector<std::string> r;
- accumulateLoggerNames(mRoot, r);
- return r;
+ std::vector<std::string> r;
+ accumulateLoggerNames(mRoot, r);
+ return r;
}
void LoggerFactory::accumulateLoggerNames(Logger const &logger, std::vector<
- std::string> &out)
+ std::string> &out)
{
- out.push_back(logger.getName());
- // recurse through the children
- std::vector<Logger const *> const &children = logger.getChildren();
- for (std::vector<Logger const *>::const_iterator i = children.begin(); i
- != children.end(); ++i)
- {
- accumulateLoggerNames(**i, out);
- }
+ out.push_back(logger.getName());
+ // recurse through the children
+ std::vector<Logger const *> const &children = logger.getChildren();
+ for (std::vector<Logger const *>::const_iterator i = children.begin(); i
+ != children.end(); ++i)
+ {
+ accumulateLoggerNames(**i, out);
+ }
}
void LoggerFactory::setLogOutput(LogOut &out)
{
- mRoot.setOutput(out);
+ mRoot.setOutput(out);
}
diff --git a/client/src/OstreamLogger.cpp b/client/src/OstreamLogger.cpp
index 90aa2e2..7465693 100644
--- a/client/src/OstreamLogger.cpp
+++ b/client/src/OstreamLogger.cpp
@@ -16,25 +16,25 @@ namespace
class OstreamLogger : public LogOut
{
public:
- OstreamLogger(std::ostream &out) :
- mOut(out)
- {
+ OstreamLogger(std::ostream &out) :
+ mOut(out)
+ {
- }
+ }
- void logs(std::string const &name, Level logLevel,
- std::string const &message)
- {
- mOut << name << ":" << logLevel << ":" << message << '\n';
- }
+ void logs(std::string const &name, Level logLevel,
+ std::string const &message)
+ {
+ mOut << name << ":" << logLevel << ":" << message << '\n';
+ }
private:
- std::ostream &mOut;
+ std::ostream &mOut;
};
}
std::auto_ptr<LogOut> AsteriskSCF::System::Logging::buildOstreamLogger(std::ostream &out)
{
- return std::auto_ptr<LogOut>(new OstreamLogger(out));
+ return std::auto_ptr<LogOut>(new OstreamLogger(out));
}
diff --git a/client/src/logger.h b/client/src/logger.h
index 82f8edf..f7a3688 100755
--- a/client/src/logger.h
+++ b/client/src/logger.h
@@ -31,29 +31,29 @@ namespace Logging
class LogBuf : public std::streambuf
{
public:
- HYDRA_ICEBOX_EXPORT LogBuf(LogOut &out, std::string const &name, Level logLevel);
+ HYDRA_ICEBOX_EXPORT LogBuf(LogOut &out, std::string const &name, Level logLevel);
- /**
- * Copy ctor.
- * @param orig Original.
- */
- HYDRA_ICEBOX_EXPORT LogBuf(LogBuf const &orig);
+ /**
+ * Copy ctor.
+ * @param orig Original.
+ */
+ HYDRA_ICEBOX_EXPORT LogBuf(LogBuf const &orig);
- HYDRA_ICEBOX_EXPORT ~LogBuf();
+ HYDRA_ICEBOX_EXPORT ~LogBuf();
protected:
- int overflow(int c);
+ int overflow(int c);
private:
- std::stringbuf mBuffer;
- LogOut &mOut;
- const std::string nName;
- const Level mLogLevel;
-
- /**
- * Sends the current buffer to out and clears it.
- */
- void sendBuffer();
+ std::stringbuf mBuffer;
+ LogOut &mOut;
+ const std::string nName;
+ const Level mLogLevel;
+
+ /**
+ * Sends the current buffer to out and clears it.
+ */
+ void sendBuffer();
};
/**
@@ -63,67 +63,67 @@ private:
class CondStream
{
public:
- CondStream(LogOut &out, std::string const &name, Level logLevel,
- bool enabled) :
- mBuf(out, name, logLevel), mStream(&mBuf), mEnabled(enabled)
- {
- }
-
- /**
- * Copy ctor.
- * @param orig Original.
- */
- CondStream(CondStream const &orig) :
- mBuf(orig.mBuf), mStream(&mBuf), mEnabled(orig.mEnabled)
- {
-
- }
-
- /**
- * Output operator. Only does something when enabled == true.
- * @param val Value to output.
- * @return this.
- */
- template<typename T>
- CondStream &operator<<(T const &val);
-
- /**
- * Output operator for manipulators, such as endl.
- */
- CondStream &operator<<(std::ostream& (*pf)(std::ostream&));
+ CondStream(LogOut &out, std::string const &name, Level logLevel,
+ bool enabled) :
+ mBuf(out, name, logLevel), mStream(&mBuf), mEnabled(enabled)
+ {
+ }
+
+ /**
+ * Copy ctor.
+ * @param orig Original.
+ */
+ CondStream(CondStream const &orig) :
+ mBuf(orig.mBuf), mStream(&mBuf), mEnabled(orig.mEnabled)
+ {
+
+ }
+
+ /**
+ * Output operator. Only does something when enabled == true.
+ * @param val Value to output.
+ * @return this.
+ */
+ template<typename T>
+ CondStream &operator<<(T const &val);
+
+ /**
+ * Output operator for manipulators, such as endl.
+ */
+ CondStream &operator<<(std::ostream& (*pf)(std::ostream&));
private:
- /**
- * streambuffer for writing characters.
- */
- LogBuf mBuf;
- /**
- * Ostream for processing output.
- */
- std::ostream mStream;
- /**
- * If false, operator<<() does nothing.
- */
- bool mEnabled;
+ /**
+ * streambuffer for writing characters.
+ */
+ LogBuf mBuf;
+ /**
+ * Ostream for processing output.
+ */
+ std::ostream mStream;
+ /**
+ * If false, operator<<() does nothing.
+ */
+ bool mEnabled;
};
template<typename T>
inline CondStream &CondStream::operator<<(T const &val)
{
- if (mEnabled)
- {
- mStream << val;
- }
- return *this;
+ if (mEnabled)
+ {
+ mStream << val;
+ }
+ return *this;
}
inline CondStream &CondStream::operator<<(std::ostream& (*pf)(std::ostream&))
{
- if (mEnabled)
- {
- mStream << pf;
- }
- return *this;
+ if (mEnabled)
+ {
+ mStream << pf;
+ }
+ return *this;
}
/**
@@ -132,124 +132,124 @@ inline CondStream &CondStream::operator<<(std::ostream& (*pf)(std::ostream&))
class Logger
{
public:
- /**
- * Construct a root Logger.
- */
- HYDRA_ICEBOX_EXPORT Logger(std::string const &name, LogOut &out, Level logLevel = Debug);
-
- /**
- * Construct a child Logger.
- */
- HYDRA_ICEBOX_EXPORT Logger(Logger const &parent, std::string const &name);
-
- HYDRA_ICEBOX_EXPORT ~Logger();
-
- /**
- * If true, this Logger would log messages of the given Level.
- *
- * @param level Level to check.
- * @return true if enabled for given level.
- */
- HYDRA_ICEBOX_EXPORT bool isEnabledFor(Level level) const
- {
- return level >= getEffectiveLevel();
- }
-
- /**
- * Ostream style logging.
- *
- * @param level Level for messages sent to this stream.
- * @return LogStream that logs at the given level.
- */
- HYDRA_ICEBOX_EXPORT CondStream operator()(Level level) const;
-
- /**
- * Log a single message.
- */
- HYDRA_ICEBOX_EXPORT void logs(Level level, std::string const &message) const;
-
- /**
- * Log a single printf-formatted message.
- */
- HYDRA_ICEBOX_EXPORT void logf(Level level, char const *fmt, ...) const;
-
- /**
- * Log a single vprintf-formatted message.
- */
- HYDRA_ICEBOX_EXPORT void vlogf(Level level, char const *fmt, va_list ap) const;
-
- Logger const *getParent() const
- {
- return mParent;
- }
-
- HYDRA_ICEBOX_EXPORT Logger &getChild(std::string const &childName);
- HYDRA_ICEBOX_EXPORT std::vector<Logger const *> getChildren() const;
-
- HYDRA_ICEBOX_EXPORT std::string const &getName() const
- {
- return mName;
- }
-
- HYDRA_ICEBOX_EXPORT LogOut &getOutput() const
- {
- return *mOut;
- }
-
- HYDRA_ICEBOX_EXPORT void setOutput(LogOut &out);
-
- /**
- * Set's the current logLevel. Until unsetLevel() is called, we are no
- * longer affected by changes to our parent's log level.
- */
- HYDRA_ICEBOX_EXPORT void setLevel(Level logLevel);
-
- /**
- * Changes our logLevel to now inherit from out parent.
- */
- HYDRA_ICEBOX_EXPORT void unsetLevel();
-
- /**
- * Returns the effective level of this Logger.
- */
- HYDRA_ICEBOX_EXPORT Level getEffectiveLevel() const;
+ /**
+ * Construct a root Logger.
+ */
+ HYDRA_ICEBOX_EXPORT Logger(std::string const &name, LogOut &out, Level logLevel = Debug);
+
+ /**
+ * Construct a child Logger.
+ */
+ HYDRA_ICEBOX_EXPORT Logger(Logger const &parent, std::string const &name);
+
+ HYDRA_ICEBOX_EXPORT ~Logger();
+
+ /**
+ * If true, this Logger would log messages of the given Level.
+ *
+ * @param level Level to check.
+ * @return true if enabled for given level.
+ */
+ HYDRA_ICEBOX_EXPORT bool isEnabledFor(Level level) const
+ {
+ return level >= getEffectiveLevel();
+ }
+
+ /**
+ * Ostream style logging.
+ *
+ * @param level Level for messages sent to this stream.
+ * @return LogStream that logs at the given level.
+ */
+ HYDRA_ICEBOX_EXPORT CondStream operator()(Level level) const;
+
+ /**
+ * Log a single message.
+ */
+ HYDRA_ICEBOX_EXPORT void logs(Level level, std::string const &message) const;
+
+ /**
+ * Log a single printf-formatted message.
+ */
+ HYDRA_ICEBOX_EXPORT void logf(Level level, char const *fmt, ...) const;
+
+ /**
+ * Log a single vprintf-formatted message.
+ */
+ HYDRA_ICEBOX_EXPORT void vlogf(Level level, char const *fmt, va_list ap) const;
+
+ Logger const *getParent() const
+ {
+ return mParent;
+ }
+
+ HYDRA_ICEBOX_EXPORT Logger &getChild(std::string const &childName);
+ HYDRA_ICEBOX_EXPORT std::vector<Logger const *> getChildren() const;
+
+ HYDRA_ICEBOX_EXPORT std::string const &getName() const
+ {
+ return mName;
+ }
+
+ HYDRA_ICEBOX_EXPORT LogOut &getOutput() const
+ {
+ return *mOut;
+ }
+
+ HYDRA_ICEBOX_EXPORT void setOutput(LogOut &out);
+
+ /**
+ * Set's the current logLevel. Until unsetLevel() is called, we are no
+ * longer affected by changes to our parent's log level.
+ */
+ HYDRA_ICEBOX_EXPORT void setLevel(Level logLevel);
+
+ /**
+ * Changes our logLevel to now inherit from out parent.
+ */
+ HYDRA_ICEBOX_EXPORT void unsetLevel();
+
+ /**
+ * Returns the effective level of this Logger.
+ */
+ HYDRA_ICEBOX_EXPORT Level getEffectiveLevel() const;
private:
- // non-copyable
- Logger(Logger const &);
- Logger const &operator=(Logger const &);
-
- /**
- * Mutex for access to the children field.
- */
- IceUtil::Mutex mChildrenMutex;
-
- /**
- * Parent pointer. We cannot change which parent we have, nor can we change
- * our parent.
- */
- Logger const * const mParent;
- /**
- * Map of children. The key is the next final node in that child's name.
- */
- std::map<std::string, Logger *> mChildren;
-
- /**
- * Name of this logger, in dotted-notation.
- */
- const std::string mName;
- /**
- * Output for log messages.
- */
- LogOut *mOut;
- /**
- * Current level of this Logger. Only applicable if inheritedLevel == false.
- */
- Level mLogLevel;
- /**
- * If true, then our effectiveLevel == parent->effectiveLevel.
- */
- bool mInheritedLevel;
+ // non-copyable
+ Logger(Logger const &);
+ Logger const &operator=(Logger const &);
+
+ /**
+ * Mutex for access to the children field.
+ */
+ IceUtil::Mutex mChildrenMutex;
+
+ /**
+ * Parent pointer. We cannot change which parent we have, nor can we change
+ * our parent.
+ */
+ Logger const * const mParent;
+ /**
+ * Map of children. The key is the next final node in that child's name.
+ */
+ std::map<std::string, Logger *> mChildren;
+
+ /**
+ * Name of this logger, in dotted-notation.
+ */
+ const std::string mName;
+ /**
+ * Output for log messages.
+ */
+ LogOut *mOut;
+ /**
+ * Current level of this Logger. Only applicable if inheritedLevel == false.
+ */
+ Level mLogLevel;
+ /**
+ * If true, then our effectiveLevel == parent->effectiveLevel.
+ */
+ bool mInheritedLevel;
};
/**
@@ -258,30 +258,30 @@ private:
class LoggerFactory
{
public:
- HYDRA_ICEBOX_EXPORT LoggerFactory(LogOut &out);
-
- /**
- * Will get the Logger with the given name. If the Logger does not exist,
- * it will be created.
- *
- * @param name Name of the Logger to be retrieved.
- * @return Ref to the Logger.
- * @thread-safe
- */
- HYDRA_ICEBOX_EXPORT Logger &getLogger(std::string const &name);
-
- /**
- * Returns a vector of the names of all currently configured Logger's.
- * @return Vector of Logger names.
- */
- HYDRA_ICEBOX_EXPORT std::vector<std::string> getLoggerNames() const;
-
- HYDRA_ICEBOX_EXPORT void setLogOutput(LogOut &out);
+ HYDRA_ICEBOX_EXPORT LoggerFactory(LogOut &out);
+
+ /**
+ * Will get the Logger with the given name. If the Logger does not exist,
+ * it will be created.
+ *
+ * @param name Name of the Logger to be retrieved.
+ * @return Ref to the Logger.
+ * @thread-safe
+ */
+ HYDRA_ICEBOX_EXPORT Logger &getLogger(std::string const &name);
+
+ /**
+ * Returns a vector of the names of all currently configured Logger's.
+ * @return Vector of Logger names.
+ */
+ HYDRA_ICEBOX_EXPORT std::vector<std::string> getLoggerNames() const;
+
+ HYDRA_ICEBOX_EXPORT void setLogOutput(LogOut &out);
private:
- Logger mRoot;
+ Logger mRoot;
- static void accumulateLoggerNames(Logger const &logger, std::vector<std::string> &out);
+ static void accumulateLoggerNames(Logger const &logger, std::vector<std::string> &out);
};
HYDRA_ICEBOX_EXPORT std::auto_ptr<LogOut> buildOstreamLogger(std::ostream &out);
diff --git a/client/test/CMakeLists.txt b/client/test/CMakeLists.txt
index 0edc06b..a3b8eda 100644
--- a/client/test/CMakeLists.txt
+++ b/client/test/CMakeLists.txt
@@ -35,7 +35,7 @@ hydra_component_add_slice(scf-log LoggerIf)
# For reasons unknown, adding this library causes duplicate symbol errors
# on Windows. But without it, Mac and Linux fail to compile
if(NOT WIN32)
- hydra_component_add_boost_libraries(scf-log program_options)
+ hydra_component_add_boost_libraries(scf-log program_options)
endif()
hydra_component_build_standalone(scf-log)
diff --git a/client/test/ExpectedLogOut.h b/client/test/ExpectedLogOut.h
index d519b81..418bfc9 100644
--- a/client/test/ExpectedLogOut.h
+++ b/client/test/ExpectedLogOut.h
@@ -23,25 +23,25 @@ namespace Logging
class ExpectedLogOut : public LogOut
{
public:
- ExpectedLogOut(std::string const &expected) :
- expected(expected)
- {
- }
-
- void logs(std::string const &name, Level logLevel,
- std::string const &message)
- {
- actual << name << ":" << logLevel << ":" << message << '\n';
- }
-
- void check()
- {
- BOOST_CHECK_EQUAL(expected, actual.str());
- }
+ ExpectedLogOut(std::string const &expected) :
+ expected(expected)
+ {
+ }
+
+ void logs(std::string const &name, Level logLevel,
+ std::string const &message)
+ {
+ actual << name << ":" << logLevel << ":" << message << '\n';
+ }
+
+ void check()
+ {
+ BOOST_CHECK_EQUAL(expected, actual.str());
+ }
private:
- std::string expected;
- std::stringstream actual;
+ std::string expected;
+ std::stringstream actual;
};
diff --git a/client/test/IceConfigurator-test.cpp b/client/test/IceConfigurator-test.cpp
index d612959..db38a4d 100644
--- a/client/test/IceConfigurator-test.cpp
+++ b/client/test/IceConfigurator-test.cpp
@@ -18,11 +18,11 @@ namespace
{
void addConfig(Configuration &cfg, std::string const &name, Level logLevel)
{
- SourceConfiguration sourceConfig = {};
- sourceConfig.name = name;
- sourceConfig.logLevel = logLevel;
+ SourceConfiguration sourceConfig = {};
+ sourceConfig.name = name;
+ sourceConfig.logLevel = logLevel;
- cfg.sourceSettings.push_back(sourceConfig);
+ cfg.sourceSettings.push_back(sourceConfig);
}
}
@@ -30,46 +30,46 @@ BOOST_AUTO_TEST_SUITE(IceConfiguratorTest)
BOOST_AUTO_TEST_CASE(test_simple)
{
- ExpectedLogOut out("");
- LoggerFactory factory(out);
- IceConfigurator uut(factory);
-
- Configuration cfg;
- addConfig(cfg, "", Error);
- addConfig(cfg, "AsteriskSCF", Info);
- addConfig(cfg, "AsteriskSCF.Core", Debug);
- addConfig(cfg, "AsteriskSCF.Media", Off);
-
- uut.configured(cfg);
-
- BOOST_CHECK_EQUAL(Error, factory.getLogger("").getEffectiveLevel());
- BOOST_CHECK_EQUAL(Info, factory.getLogger("AsteriskSCF").getEffectiveLevel());
- BOOST_CHECK_EQUAL(Debug, factory.getLogger("AsteriskSCF.Core").getEffectiveLevel());
- BOOST_CHECK_EQUAL(Off, factory.getLogger("AsteriskSCF.Media").getEffectiveLevel());
+ ExpectedLogOut out("");
+ LoggerFactory factory(out);
+ IceConfigurator uut(factory);
+
+ Configuration cfg;
+ addConfig(cfg, "", Error);
+ addConfig(cfg, "AsteriskSCF", Info);
+ addConfig(cfg, "AsteriskSCF.Core", Debug);
+ addConfig(cfg, "AsteriskSCF.Media", Off);
+
+ uut.configured(cfg);
+
+ BOOST_CHECK_EQUAL(Error, factory.getLogger("").getEffectiveLevel());
+ BOOST_CHECK_EQUAL(Info, factory.getLogger("AsteriskSCF").getEffectiveLevel());
+ BOOST_CHECK_EQUAL(Debug, factory.getLogger("AsteriskSCF.Core").getEffectiveLevel());
+ BOOST_CHECK_EQUAL(Off, factory.getLogger("AsteriskSCF.Media").getEffectiveLevel());
}
BOOST_AUTO_TEST_CASE(test_reset)
{
- ExpectedLogOut out("");
- LoggerFactory factory(out);
- IceConfigurator uut(factory);
-
- Configuration cfg;
- addConfig(cfg, "", Error);
- addConfig(cfg, "AsteriskSCF", Info);
- addConfig(cfg, "AsteriskSCF.Core", Debug);
- addConfig(cfg, "AsteriskSCF.Media", Off);
- uut.configured(cfg);
-
- cfg.sourceSettings.clear();
- addConfig(cfg, "", Critical);
- uut.configured(cfg);
-
- BOOST_CHECK_EQUAL(Critical, factory.getLogger("").getEffectiveLevel());
- BOOST_CHECK_EQUAL(Critical, factory.getLogger("AsteriskSCF").getEffectiveLevel());
- BOOST_CHECK_EQUAL(Critical, factory.getLogger("AsteriskSCF.Core").getEffectiveLevel());
- BOOST_CHECK_EQUAL(Critical, factory.getLogger("AsteriskSCF.Media").getEffectiveLevel());
+ ExpectedLogOut out("");
+ LoggerFactory factory(out);
+ IceConfigurator uut(factory);
+
+ Configuration cfg;
+ addConfig(cfg, "", Error);
+ addConfig(cfg, "AsteriskSCF", Info);
+ addConfig(cfg, "AsteriskSCF.Core", Debug);
+ addConfig(cfg, "AsteriskSCF.Media", Off);
+ uut.configured(cfg);
+
+ cfg.sourceSettings.clear();
+ addConfig(cfg, "", Critical);
+ uut.configured(cfg);
+
+ BOOST_CHECK_EQUAL(Critical, factory.getLogger("").getEffectiveLevel());
+ BOOST_CHECK_EQUAL(Critical, factory.getLogger("AsteriskSCF").getEffectiveLevel());
+ BOOST_CHECK_EQUAL(Critical, factory.getLogger("AsteriskSCF.Core").getEffectiveLevel());
+ BOOST_CHECK_EQUAL(Critical, factory.getLogger("AsteriskSCF.Media").getEffectiveLevel());
}
BOOST_AUTO_TEST_SUITE_END()
diff --git a/client/test/LogBuf-test.cpp b/client/test/LogBuf-test.cpp
index 8979aef..04908b8 100644
--- a/client/test/LogBuf-test.cpp
+++ b/client/test/LogBuf-test.cpp
@@ -18,22 +18,22 @@ 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);
+ ExpectedLogOut out("src:Info:testing\n");
+ LogBuf uut(out, "src", Info);
+ std::ostream stream(&uut);
- stream << "testing" << '\n';
- out.check();
+ 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);
+ ExpectedLogOut out("src:Debug:debug f00d\n");
+ LogBuf buf(out, "src", Debug);
+ std::ostream uut(&buf);
- uut << "debug " << std::hex << 61453 << '\n';
- out.check();
+ 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 f538d81..df18fb2 100644
--- a/client/test/Logger-test.cpp
+++ b/client/test/Logger-test.cpp
@@ -17,93 +17,93 @@ BOOST_AUTO_TEST_SUITE( LoggerTest )
BOOST_AUTO_TEST_CASE( test_log )
{
- ExpectedLogOut out("src:Critical:Critical Message\n");
- Logger uut("src", out, Debug);
+ ExpectedLogOut out("src:Critical:Critical Message\n");
+ Logger uut("src", out, Debug);
- uut.logs(Critical, "Critical Message");
- out.check();
+ uut.logs(Critical, "Critical Message");
+ out.check();
}
BOOST_AUTO_TEST_CASE( test_logf )
{
- ExpectedLogOut out("src:Critical:Critical message f00d\n");
- Logger uut("src", out, Debug);
+ ExpectedLogOut out("src:Critical:Critical message f00d\n");
+ Logger uut("src", out, Debug);
- uut.logf(Critical, "Critical message %04x", 61453);
- out.check();
+ uut.logf(Critical, "Critical message %04x", 61453);
+ out.check();
}
BOOST_AUTO_TEST_CASE( test_same_level )
{
- ExpectedLogOut out("src:Debug:debug\n");
- Logger uut("src", out, Debug);
+ ExpectedLogOut out("src:Debug:debug\n");
+ Logger uut("src", out, Debug);
- uut.logs(Debug, "debug");
- out.check();
+ uut.logs(Debug, "debug");
+ out.check();
}
BOOST_AUTO_TEST_CASE( test_log_squelched )
{
- ExpectedLogOut out("");
- Logger uut("src", out, Info);
+ ExpectedLogOut out("");
+ Logger uut("src", out, Info);
- uut.logs(Debug, "debug\n");
- out.check();
+ uut.logs(Debug, "debug\n");
+ out.check();
}
BOOST_AUTO_TEST_CASE(test_stream_on)
{
- ExpectedLogOut out("src:Debug:debug\n");
- Logger uut("src", out, Debug);
+ ExpectedLogOut out("src:Debug:debug\n");
+ Logger uut("src", out, Debug);
- uut(Debug) << "debug\n";
- out.check();
+ uut(Debug) << "debug\n";
+ out.check();
}
BOOST_AUTO_TEST_CASE(test_stream_off)
{
- ExpectedLogOut out("");
- Logger uut("src", out, Info);
+ ExpectedLogOut out("");
+ Logger uut("src", out, Info);
- uut(Debug) << "debug\n";
- out.check();
+ uut(Debug) << "debug\n";
+ out.check();
}
BOOST_AUTO_TEST_CASE(test_stream)
{
- ExpectedLogOut out("src:Info:testing\n");
- Logger uut("src", out, Info);
+ ExpectedLogOut out("src:Info:testing\n");
+ Logger uut("src", out, Info);
- uut(Info) << "testing" << '\n';
- out.check();
+ 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);
+ ExpectedLogOut out("src:Debug:debug f00d\n");
+ Logger uut("src", out, Debug);
- uut(Debug) << "debug " << std::hex << 61453 << '\n';
- out.check();
+ 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);
+ ExpectedLogOut out("src:Debug:debug\nsrc:Info:info\n");
+ Logger uut("src", out, Debug);
- uut(Debug) << "debug";
- uut(Info) << "info";
- out.check();
+ uut(Debug) << "debug";
+ uut(Info) << "info";
+ out.check();
}
BOOST_AUTO_TEST_CASE(test_endl)
{
- ExpectedLogOut out("src:Info:testing\n");
- Logger uut("src", out, Info);
+ ExpectedLogOut out("src:Info:testing\n");
+ Logger uut("src", out, Info);
- uut(Info) << "testing" << std::endl;
- out.check();
+ uut(Info) << "testing" << std::endl;
+ out.check();
}
BOOST_AUTO_TEST_SUITE_END()
diff --git a/client/test/LoggerFactory-test.cpp b/client/test/LoggerFactory-test.cpp
index 3b84437..890d1c3 100644
--- a/client/test/LoggerFactory-test.cpp
+++ b/client/test/LoggerFactory-test.cpp
@@ -17,62 +17,62 @@ BOOST_AUTO_TEST_SUITE(LoggerFactoryTest)
BOOST_AUTO_TEST_CASE(testGetDistinct)
{
- std::stringstream tmp;
- std::auto_ptr<LogOut> logOut = buildOstreamLogger(tmp);
- LoggerFactory uut(*logOut);
+ std::stringstream tmp;
+ std::auto_ptr<LogOut> logOut = buildOstreamLogger(tmp);
+ LoggerFactory uut(*logOut);
- Logger const &asteriskScf = uut.getLogger("AsteriskSCF");
- Logger const &core = uut.getLogger("AsteriskSCF.Core");
+ Logger const &asteriskScf = uut.getLogger("AsteriskSCF");
+ Logger const &core = uut.getLogger("AsteriskSCF.Core");
- BOOST_CHECK_NE(&core, &asteriskScf);
- BOOST_CHECK_EQUAL(&asteriskScf, core.getParent());
- BOOST_CHECK_EQUAL(&uut.getLogger(""), asteriskScf.getParent());
+ BOOST_CHECK_NE(&core, &asteriskScf);
+ BOOST_CHECK_EQUAL(&asteriskScf, core.getParent());
+ BOOST_CHECK_EQUAL(&uut.getLogger(""), asteriskScf.getParent());
}
BOOST_AUTO_TEST_CASE(testInheritence_off)
{
- std::stringstream actual;
- std::auto_ptr<LogOut> logOut = buildOstreamLogger(actual);
- LoggerFactory uut(*logOut);
+ std::stringstream actual;
+ std::auto_ptr<LogOut> logOut = buildOstreamLogger(actual);
+ LoggerFactory uut(*logOut);
- Logger &root = uut.getLogger("");
- Logger &asteriskScf = uut.getLogger("AsteriskSCF");
+ Logger &root = uut.getLogger("");
+ Logger &asteriskScf = uut.getLogger("AsteriskSCF");
- root.setLevel(Off);
+ root.setLevel(Off);
- asteriskScf.logs(Debug, "Should not log");
- BOOST_CHECK_EQUAL("", actual.str());
+ asteriskScf.logs(Debug, "Should not log");
+ BOOST_CHECK_EQUAL("", actual.str());
}
BOOST_AUTO_TEST_CASE(testInheritence_on)
{
- std::stringstream actual;
- std::auto_ptr<LogOut> logOut = buildOstreamLogger(actual);
- LoggerFactory uut(*logOut);
+ std::stringstream actual;
+ std::auto_ptr<LogOut> logOut = buildOstreamLogger(actual);
+ LoggerFactory uut(*logOut);
- Logger &root = uut.getLogger("");
- Logger &asteriskScf = uut.getLogger("AsteriskSCF");
+ Logger &root = uut.getLogger("");
+ Logger &asteriskScf = uut.getLogger("AsteriskSCF");
- root.setLevel(Debug);
+ root.setLevel(Debug);
- asteriskScf.logs(Debug, "Should log");
... 1434 lines suppressed ...
--
asterisk-scf/integration/logger.git
More information about the asterisk-scf-commits
mailing list