[asterisk-scf-commits] asterisk-scf/release/logger.git branch "master" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Tue Sep 20 11:41:12 CDT 2011
branch "master" has been updated
via f09864c318aef8135d49204db7d268a0e56bef11 (commit)
from b7ef57dd33f9efa42dc85a5dddd51876c2f0f2ef (commit)
Summary of changes:
client/src/IceLogger.cpp | 4 ++--
client/src/Logger.cpp | 30 ++++++++++++++++++++++++++++--
include/AsteriskSCF/Logger/IceLogger.h | 2 +-
include/AsteriskSCF/Logger/LogOut.h | 8 ++++----
include/AsteriskSCF/logger.h | 14 ++++++++++----
server/src/CMakeLists.txt | 1 +
6 files changed, 46 insertions(+), 13 deletions(-)
- Log -----------------------------------------------------------------
commit f09864c318aef8135d49204db7d268a0e56bef11
Author: Brent Eagles <beagles at digium.com>
Date: Tue Sep 20 14:07:22 2011 -0230
Fix a reference count bug in the logger client library that would cause the
LogOut object to be destroyed once the IceLogger factory goes out of scope IF
it were TopicManager.Proxy was NOT defined as the servant would not be added to
the object adapter. The current fix is to add it to the adapter regardless. It
will be cleaned up when the adapter is destroyed.
Also added assignment operator (prob unnecessary, was written whilst tracking
down the above issue), and moved the DLL export macro to the class
declaration instead of the individual methods.
Also added LogOut to the server project since it was missing linking with
the destructor.
diff --git a/client/src/IceLogger.cpp b/client/src/IceLogger.cpp
index 070c1b2..0b2d50f 100644
--- a/client/src/IceLogger.cpp
+++ b/client/src/IceLogger.cpp
@@ -247,6 +247,7 @@ ConfiguredIceLoggerPtr AsteriskSCF::System::Logging::createIceLogger(
}
ConfiguredIceLoggerPtr logger = ConfiguredIceLogger::create(locator, serviceName);
+ Ice::ObjectPrx proxy = adapter->addWithUUID(logger);
IceStorm::TopicManagerPrx topicManager =
IceStorm::TopicManagerPrx::uncheckedCast(
@@ -256,11 +257,10 @@ ConfiguredIceLoggerPtr AsteriskSCF::System::Logging::createIceLogger(
{
try
{
- Ice::ObjectPrx proxy = adapter->addWithUUID(logger)->ice_oneway();
IceStorm::TopicPrx topic = topicManager->retrieve(Discovery::TOPIC);
if (topic)
{
- topic->subscribeAndGetPublisher(IceStorm::QoS(), proxy);
+ topic->subscribeAndGetPublisher(IceStorm::QoS(), proxy->ice_oneway());
}
}
catch (const std::exception& e)
diff --git a/client/src/Logger.cpp b/client/src/Logger.cpp
index f06015a..7de61e3 100644
--- a/client/src/Logger.cpp
+++ b/client/src/Logger.cpp
@@ -55,6 +55,21 @@ LogBuf::~LogBuf()
}
}
+LogBuf& LogBuf::operator=(const LogBuf& rhs)
+{
+ if (this == &rhs)
+ {
+ return *this;
+ }
+ if (!mBuffer.str().empty())
+ {
+ sendBuffer();
+ }
+ mOut = rhs.mOut;
+ mName = rhs.mName;
+ mLogLevel = rhs.mLogLevel;
+ return *this;
+}
int LogBuf::overflow(int c)
{
@@ -73,7 +88,18 @@ void LogBuf::sendBuffer()
// throws an exception, we still want to clear the buffer.
const std::string& message = mBuffer.str();
mBuffer.str("");
- mOut.logs(mName,mLogLevel,message);
+ try
+ {
+ mOut.logs(mName,mLogLevel,message);
+ }
+ catch (...)
+ {
+ //
+ // Where sendBuffer is called from an destructor, we really don't want exceptions
+ // coming out of logs()
+ //
+ std::cerr << "An exception occurred when outputting log data" << std::endl;
+ }
}
@@ -99,7 +125,7 @@ Logger::LoggerImpl::~LoggerImpl()
CondStream Logger::LoggerImpl::operator()(Level level) const
{
- return CondStream(*mOut,mName,level,isEnabledFor(level));
+ return CondStream(*mOut, mName, level, isEnabledFor(level));
}
diff --git a/include/AsteriskSCF/Logger/IceLogger.h b/include/AsteriskSCF/Logger/IceLogger.h
index 487b834..8f3c012 100644
--- a/include/AsteriskSCF/Logger/IceLogger.h
+++ b/include/AsteriskSCF/Logger/IceLogger.h
@@ -34,7 +34,7 @@ public:
void setComponentInfo(const std::string& componentCategory,
const std::string& serviceName,
const std::string& id);
- const LoggingServerPrx& getServer() const { return mServer; }
+ const LoggingServerPrx getServer() const { return mServer; }
void setServer(const LoggingServerPrx& server) { this->mServer = server; }
private:
diff --git a/include/AsteriskSCF/Logger/LogOut.h b/include/AsteriskSCF/Logger/LogOut.h
index 78ee517..6523e53 100644
--- a/include/AsteriskSCF/Logger/LogOut.h
+++ b/include/AsteriskSCF/Logger/LogOut.h
@@ -32,13 +32,13 @@ namespace Logging
*
* NOTE: it is your responsibility to make sure your LogOut implementation is threadsafe
*/
-class LogOut
+class ASTSCF_DLL_EXPORT LogOut
{
public:
- ASTSCF_DLL_EXPORT virtual ~LogOut();
- ASTSCF_DLL_EXPORT virtual void logs(const std::string& name, Level logLevel,
+ virtual ~LogOut();
+ virtual void logs(const std::string& name, Level logLevel,
const std::string& message) = 0;
- ASTSCF_DLL_EXPORT virtual void setComponentInfo(
+ virtual void setComponentInfo(
const std::string& componentCategory,
const std::string& serviceName,
const std::string& id) = 0;
diff --git a/include/AsteriskSCF/logger.h b/include/AsteriskSCF/logger.h
index ad790fc..158cdd4 100644
--- a/include/AsteriskSCF/logger.h
+++ b/include/AsteriskSCF/logger.h
@@ -45,18 +45,24 @@ namespace Logging
* or when destroyed. The way temporary object lifecycles work in C++, this is
* very convenient.
*/
-class LogBuf : public std::streambuf
+class ASTSCF_DLL_EXPORT LogBuf : public std::streambuf
{
public:
- ASTSCF_DLL_EXPORT LogBuf(LogOut& out, const std::string& name, Level logLevel);
+ LogBuf(LogOut& out, const std::string& name, Level logLevel);
/**
* Copy ctor.
* @param orig Original.
*/
- ASTSCF_DLL_EXPORT LogBuf(const LogBuf& orig);
+ LogBuf(const LogBuf& orig);
- ASTSCF_DLL_EXPORT ~LogBuf();
+ ~LogBuf();
+
+
+ /**
+ * Assignment probably never gets used, but just in case.
+ */
+ LogBuf& operator=(const LogBuf& orig);
protected:
int overflow(int c);
diff --git a/server/src/CMakeLists.txt b/server/src/CMakeLists.txt
index a532caa..cb4f86f 100644
--- a/server/src/CMakeLists.txt
+++ b/server/src/CMakeLists.txt
@@ -13,6 +13,7 @@ astscf_component_add_files(logging-service-lib OstreamChainedLogOut.h)
astscf_component_add_files(logging-service-lib LoggingServer.h)
astscf_component_add_files(logging-service-lib Configuration.h)
astscf_component_add_files(logging-service-lib ../../client/src/LogFormatter.cpp)
+astscf_component_add_files(logging-service-lib ../../client/src/LogOut.cpp)
astscf_component_add_slices(logging-service-lib PROJECT AsteriskSCF/Configuration/LoggingService/LoggingConfigurationIf.ice)
astscf_component_add_boost_libraries(logging-service-lib core thread filesystem date_time system)
astscf_component_add_ice_libraries(logging-service-lib IceStorm)
-----------------------------------------------------------------------
--
asterisk-scf/release/logger.git
More information about the asterisk-scf-commits
mailing list