summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorDwayne Boone <dwayne@zeroc.com>2008-04-29 12:51:34 -0230
committerDwayne Boone <dwayne@zeroc.com>2008-04-29 12:51:34 -0230
commit5b4a2a64b06d1aaecb939d4f76f71aae50d76fa7 (patch)
treec3f091d08d802283767a57ad4d101799e7bbe2e3 /cpp
parentbug 711 - Python + unicode (diff)
downloadice-5b4a2a64b06d1aaecb939d4f76f71aae50d76fa7.tar.bz2
ice-5b4a2a64b06d1aaecb939d4f76f71aae50d76fa7.tar.xz
ice-5b4a2a64b06d1aaecb939d4f76f71aae50d76fa7.zip
Bug 2433 - new logger plugin mechanism
Diffstat (limited to 'cpp')
-rw-r--r--cpp/include/Ice/LoggerUtil.h18
-rw-r--r--cpp/src/Ice/Instance.cpp8
-rw-r--r--cpp/src/Ice/Instance.h1
-rw-r--r--cpp/src/Ice/LoggerUtil.cpp29
4 files changed, 56 insertions, 0 deletions
diff --git a/cpp/include/Ice/LoggerUtil.h b/cpp/include/Ice/LoggerUtil.h
index 5f33ca0b466..8028e10aece 100644
--- a/cpp/include/Ice/LoggerUtil.h
+++ b/cpp/include/Ice/LoggerUtil.h
@@ -11,6 +11,8 @@
#define ICE_LOGGER_UTIL_H
#include <Ice/LoggerF.h>
+#include <Ice/CommunicatorF.h>
+#include <Ice/Plugin.h>
namespace Ice
{
@@ -147,6 +149,22 @@ template<class Y>
ICE_API Trace& operator<<(Trace&, std::ios_base& (*)(std::ios_base&));
+//
+// A special plugin that sets logger during construction (when the provided logger is not
+// null). Both initialize and destroy are no-op. See Ice::InitializationData.
+//
+
+class ICE_API IceLoggerPlugin : public Ice::Plugin
+{
+public:
+
+ IceLoggerPlugin(const CommunicatorPtr& communicator, const LoggerPtr&);
+
+ virtual void initialize();
+
+ virtual void destroy();
+};
+
}
#endif
diff --git a/cpp/src/Ice/Instance.cpp b/cpp/src/Ice/Instance.cpp
index c9130813663..6a56fdfa3bd 100644
--- a/cpp/src/Ice/Instance.cpp
+++ b/cpp/src/Ice/Instance.cpp
@@ -757,6 +757,14 @@ IceInternal::Instance::setWstringConverter(const Ice::WstringConverterPtr& wstri
_initData.wstringConverter = wstringConverter;
}
+void
+IceInternal::Instance::setLogger(const Ice::LoggerPtr& logger)
+{
+ //
+ // No locking, as it can only be called during plugin loading
+ //
+ _initData.logger = logger;
+}
IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const InitializationData& initData) :
_state(StateActive),
diff --git a/cpp/src/Ice/Instance.h b/cpp/src/Ice/Instance.h
index 970ecda0c63..f0aa50a80b8 100644
--- a/cpp/src/Ice/Instance.h
+++ b/cpp/src/Ice/Instance.h
@@ -98,6 +98,7 @@ public:
void setStringConverter(const Ice::StringConverterPtr&);
void setWstringConverter(const Ice::WstringConverterPtr&);
+ void setLogger(const Ice::LoggerPtr&);
private:
diff --git a/cpp/src/Ice/LoggerUtil.cpp b/cpp/src/Ice/LoggerUtil.cpp
index a57b749b701..e015980c6d0 100644
--- a/cpp/src/Ice/LoggerUtil.cpp
+++ b/cpp/src/Ice/LoggerUtil.cpp
@@ -9,6 +9,9 @@
#include <Ice/LoggerUtil.h>
#include <Ice/Logger.h>
+#include <Ice/Plugin.h>
+#include <Ice/LocalException.h>
+#include <Ice/Instance.h>
using namespace std;
using namespace Ice;
@@ -150,3 +153,29 @@ Ice::operator<<(Trace& out, ios_base& (*val)(ios_base&))
out.__str() << val;
return out;
}
+
+Ice::IceLoggerPlugin::IceLoggerPlugin(const CommunicatorPtr& communicator,
+ const LoggerPtr& logger)
+{
+ if(communicator == 0)
+ {
+ throw PluginInitializationException(__FILE__, __LINE__, "Communicator cannot be null");
+ }
+
+ IceInternal::InstancePtr instance = IceInternal::getInstance(communicator);
+
+ if(logger != 0)
+ {
+ instance->setLogger(logger);
+ }
+}
+
+void
+Ice::IceLoggerPlugin::initialize()
+{
+}
+
+void
+Ice::IceLoggerPlugin::destroy()
+{
+}