diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2007-01-04 18:10:25 +0000 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2007-01-04 18:10:25 +0000 |
commit | 34f1bc04579509b0577a5b887e77c1a53cb3c886 (patch) | |
tree | 9fe3d1153363c996b2e79355f78825c5a8681566 /py/modules/IcePy/Logger.cpp | |
parent | Fixed bug 1541. (diff) | |
download | ice-34f1bc04579509b0577a5b887e77c1a53cb3c886.tar.bz2 ice-34f1bc04579509b0577a5b887e77c1a53cb3c886.tar.xz ice-34f1bc04579509b0577a5b887e77c1a53cb3c886.zip |
Added process logger
Diffstat (limited to 'py/modules/IcePy/Logger.cpp')
-rw-r--r-- | py/modules/IcePy/Logger.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/py/modules/IcePy/Logger.cpp b/py/modules/IcePy/Logger.cpp index 7881e629305..a80a253a65d 100644 --- a/py/modules/IcePy/Logger.cpp +++ b/py/modules/IcePy/Logger.cpp @@ -11,6 +11,7 @@ # include <IceUtil/Config.h> #endif #include <Logger.h> +#include <Ice/Initialize.h> using namespace std; using namespace IcePy; @@ -314,3 +315,64 @@ IcePy::createLogger(const Ice::LoggerPtr& logger) } return (PyObject*)obj; } + +extern "C" +PyObject* +IcePy_getProcessLogger(PyObject* /*self*/) +{ + Ice::LoggerPtr logger; + try + { + logger = Ice::getProcessLogger(); + } + catch(const Ice::Exception& ex) + { + IcePy::setPythonException(ex); + return NULL; + } + + // + // The process logger can either be a C++ object (such as + // the default logger supplied by the Ice run time), or a C++ + // wrapper around a Python implementation. If the latter, we + // return it directly. Otherwise, we create a Python object + // that delegates to the C++ object. + // + LoggerWrapperPtr wrapper = LoggerWrapperPtr::dynamicCast(logger); + if(wrapper) + { + PyObject* obj = wrapper->getObject(); + Py_INCREF(obj); + return obj; + } + + return createLogger(logger); +} + +extern "C" +PyObject* +IcePy_setProcessLogger(PyObject* /*self*/, PyObject* args) +{ + PyObject* loggerType = lookupType("Ice.Logger"); + assert(loggerType != NULL); + + PyObject* logger; + if(!PyArg_ParseTuple(args, STRCAST("O!"), loggerType, &logger)) + { + return NULL; + } + + Ice::LoggerPtr wrapper = new LoggerWrapper(logger); + try + { + Ice::setProcessLogger(wrapper); + } + catch(const Ice::Exception& ex) + { + IcePy::setPythonException(ex); + return NULL; + } + + Py_INCREF(Py_None); + return Py_None; +} |