summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorDwayne Boone <dwayne@zeroc.com>2006-12-11 14:58:49 +0000
committerDwayne Boone <dwayne@zeroc.com>2006-12-11 14:58:49 +0000
commit2246ef4753f62af6dd49800f217017e63c9a80d8 (patch)
tree0e8389692f367b6131d6be60a290b0d26270b4e6 /cpp
parentAdded LoggerPlugin (diff)
downloadice-2246ef4753f62af6dd49800f217017e63c9a80d8.tar.bz2
ice-2246ef4753f62af6dd49800f217017e63c9a80d8.tar.xz
ice-2246ef4753f62af6dd49800f217017e63c9a80d8.zip
Added Logger Plugin
Diffstat (limited to 'cpp')
-rw-r--r--cpp/config/PropertyNames.def1
-rw-r--r--cpp/src/Ice/Instance.cpp6
-rw-r--r--cpp/src/Ice/PluginManagerI.cpp57
-rw-r--r--cpp/src/Ice/PluginManagerI.h6
-rw-r--r--cpp/src/Ice/PropertyNames.cpp3
-rw-r--r--cpp/src/Ice/PropertyNames.h2
6 files changed, 59 insertions, 16 deletions
diff --git a/cpp/config/PropertyNames.def b/cpp/config/PropertyNames.def
index d663066c1e7..96f9e4433e9 100644
--- a/cpp/config/PropertyNames.def
+++ b/cpp/config/PropertyNames.def
@@ -143,6 +143,7 @@ Ice:
GC.Interval
ImplicitContext
InitPlugins
+ LoggerPlugin
MessageSizeMax
MonitorConnections
Nohup
diff --git a/cpp/src/Ice/Instance.cpp b/cpp/src/Ice/Instance.cpp
index fe3a13ff113..8cf07bdf2e4 100644
--- a/cpp/src/Ice/Instance.cpp
+++ b/cpp/src/Ice/Instance.cpp
@@ -743,6 +743,12 @@ IceInternal::Instance::finishSetup(int& argc, char* argv[])
assert(pluginManagerImpl);
pluginManagerImpl->loadPlugins(argc, argv);
+ LoggerPtr logger = pluginManagerImpl->getLogger();
+ if(logger)
+ {
+ _initData.logger = logger;
+ }
+
//
// Get default router and locator proxies. Don't move this
// initialization before the plug-in initialization!!! The proxies
diff --git a/cpp/src/Ice/PluginManagerI.cpp b/cpp/src/Ice/PluginManagerI.cpp
index c5cf4648f0e..bcb91b667d0 100644
--- a/cpp/src/Ice/PluginManagerI.cpp
+++ b/cpp/src/Ice/PluginManagerI.cpp
@@ -22,6 +22,7 @@ using namespace IceInternal;
const char * const Ice::PluginManagerI::_kindOfObject = "plugin";
typedef Ice::Plugin* (*PLUGIN_FACTORY)(const CommunicatorPtr&, const string&, const StringSeq&);
+typedef Ice::Logger* (*LOGGER_FACTORY)(const CommunicatorPtr&, const StringSeq&);
void
Ice::PluginManagerI::initializePlugins()
@@ -125,6 +126,7 @@ Ice::PluginManagerI::destroy()
r->second = 0;
}
+ _logger = 0;
_communicator = 0;
}
@@ -192,7 +194,7 @@ Ice::PluginManagerI::loadPlugins(int& argc, char* argv[])
PropertyDict::iterator q = plugins.find("Ice.Plugin." + name);
if(q != plugins.end())
{
- loadPlugin(name, q->second, cmdArgs);
+ loadPlugin(name, q->second, cmdArgs, false);
plugins.erase(q);
}
else
@@ -211,7 +213,13 @@ Ice::PluginManagerI::loadPlugins(int& argc, char* argv[])
for(p = plugins.begin(); p != plugins.end(); ++p)
{
string name = p->first.substr(prefix.size());
- loadPlugin(name, p->second, cmdArgs);
+ loadPlugin(name, p->second, cmdArgs, false);
+ }
+
+ string loggerStr = properties->getProperty("Ice.LoggerPlugin");
+ if(loggerStr.length() != 0)
+ {
+ loadPlugin("Logger", loggerStr, cmdArgs, true);
}
stringSeqToArgs(cmdArgs, argc, argv);
@@ -228,7 +236,7 @@ Ice::PluginManagerI::loadPlugins(int& argc, char* argv[])
}
void
-Ice::PluginManagerI::loadPlugin(const string& name, const string& pluginSpec, StringSeq& cmdArgs)
+Ice::PluginManagerI::loadPlugin(const string& name, const string& pluginSpec, StringSeq& cmdArgs, bool isLogger)
{
assert(_communicator);
@@ -296,18 +304,41 @@ Ice::PluginManagerI::loadPlugin(const string& name, const string& pluginSpec, St
// Invoke the factory function. No exceptions can be raised
// by the factory function because it's declared extern "C".
//
- PLUGIN_FACTORY factory = (PLUGIN_FACTORY)sym;
- plugin = factory(_communicator, name, args);
- if(!plugin)
+ if(isLogger)
{
- PluginInitializationException e(__FILE__, __LINE__);
- ostringstream out;
- out << "failure in entry point `" << entryPoint << "'";
- e.reason = out.str();
- throw e;
+ LOGGER_FACTORY factory = (LOGGER_FACTORY)sym;
+ _logger = factory(_communicator, args);
+ if(!_logger)
+ {
+ PluginInitializationException e(__FILE__, __LINE__);
+ ostringstream out;
+ out << "failure in entry point `" << entryPoint << "'";
+ e.reason = out.str();
+ throw e;
+ }
}
+ else
+ {
+ PLUGIN_FACTORY factory = (PLUGIN_FACTORY)sym;
+ plugin = factory(_communicator, name, args);
+ if(!plugin)
+ {
+ PluginInitializationException e(__FILE__, __LINE__);
+ ostringstream out;
+ out << "failure in entry point `" << entryPoint << "'";
+ e.reason = out.str();
+ throw e;
+ }
+ _plugins[name] = plugin;
+ _initOrder.push_back(plugin);
+ }
_libraries->add(library);
- _plugins[name] = plugin;
- _initOrder.push_back(plugin);
}
+
+Ice::LoggerPtr
+Ice::PluginManagerI::getLogger() const
+{
+ return _logger;
+}
+
diff --git a/cpp/src/Ice/PluginManagerI.h b/cpp/src/Ice/PluginManagerI.h
index 5a5460c2427..042515c06d6 100644
--- a/cpp/src/Ice/PluginManagerI.h
+++ b/cpp/src/Ice/PluginManagerI.h
@@ -13,6 +13,7 @@
#include <Ice/Plugin.h>
#include <Ice/InstanceF.h>
#include <Ice/CommunicatorF.h>
+#include <Ice/LoggerF.h>
#include <Ice/DynamicLibraryF.h>
#include <Ice/BuiltinSequences.h>
#include <IceUtil/Mutex.h>
@@ -36,7 +37,8 @@ private:
friend class IceInternal::Instance;
void loadPlugins(int&, char*[]);
- void loadPlugin(const std::string&, const std::string&, StringSeq&);
+ void loadPlugin(const std::string&, const std::string&, StringSeq&, bool);
+ LoggerPtr getLogger() const;
CommunicatorPtr _communicator;
IceInternal::DynamicLibraryListPtr _libraries;
@@ -45,6 +47,8 @@ private:
std::vector<PluginPtr> _initOrder;
bool _initialized;
static const char * const _kindOfObject;
+
+ LoggerPtr _logger;
};
}
diff --git a/cpp/src/Ice/PropertyNames.cpp b/cpp/src/Ice/PropertyNames.cpp
index c4be2fac535..2449070ce72 100644
--- a/cpp/src/Ice/PropertyNames.cpp
+++ b/cpp/src/Ice/PropertyNames.cpp
@@ -7,7 +7,7 @@
//
// **********************************************************************
-// Generated by makeprops.py from file `./config/PropertyNames.def', Mon Dec 4 13:26:07 2006
+// Generated by makeprops.py from file `./config/PropertyNames.def', Mon Dec 11 11:13:50 2006
// IMPORTANT: Do not edit this file -- any edits made here will be lost!
@@ -45,6 +45,7 @@ const char* IceInternal::PropertyNames::IceProps[] =
"Ice.GC.Interval",
"Ice.ImplicitContext",
"Ice.InitPlugins",
+ "Ice.LoggerPlugin",
"Ice.MessageSizeMax",
"Ice.MonitorConnections",
"Ice.Nohup",
diff --git a/cpp/src/Ice/PropertyNames.h b/cpp/src/Ice/PropertyNames.h
index f28e0c564be..5df9ba17997 100644
--- a/cpp/src/Ice/PropertyNames.h
+++ b/cpp/src/Ice/PropertyNames.h
@@ -7,7 +7,7 @@
//
// **********************************************************************
-// Generated by makeprops.py from file `./config/PropertyNames.def', Mon Dec 4 13:26:07 2006
+// Generated by makeprops.py from file `./config/PropertyNames.def', Mon Dec 11 11:13:50 2006
// IMPORTANT: Do not edit this file -- any edits made here will be lost!