summaryrefslogtreecommitdiff
path: root/py/modules/IcePy/Logger.cpp
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2005-01-13 16:53:41 +0000
committerMark Spruiell <mes@zeroc.com>2005-01-13 16:53:41 +0000
commit900726b7db0ad2567d041925c8999b0b1524a789 (patch)
tree090557df20df47644cd8e1007771d32025b5dccc /py/modules/IcePy/Logger.cpp
parentadded missing LoggerI (diff)
downloadice-900726b7db0ad2567d041925c8999b0b1524a789.tar.bz2
ice-900726b7db0ad2567d041925c8999b0b1524a789.tar.xz
ice-900726b7db0ad2567d041925c8999b0b1524a789.zip
adding print operation
Diffstat (limited to 'py/modules/IcePy/Logger.cpp')
-rw-r--r--py/modules/IcePy/Logger.cpp45
1 files changed, 43 insertions, 2 deletions
diff --git a/py/modules/IcePy/Logger.cpp b/py/modules/IcePy/Logger.cpp
index 508d764ece0..475d94932b4 100644
--- a/py/modules/IcePy/Logger.cpp
+++ b/py/modules/IcePy/Logger.cpp
@@ -37,6 +37,7 @@ public:
LoggerWrapper(PyObject*);
+ virtual void print(const string&);
virtual void trace(const string&, const string&);
virtual void warning(const string&);
virtual void error(const string&);
@@ -55,11 +56,22 @@ IcePy::LoggerWrapper::LoggerWrapper(PyObject* logger) :
}
void
+IcePy::LoggerWrapper::print(const string& message)
+{
+ AdoptThread adoptThread; // Ensure the current thread is able to call into Python.
+
+ PyObjectHandle tmp = PyObject_CallMethod(_logger.get(), "print", "s", message.c_str());
+ if(tmp.get() == NULL)
+ {
+ throwPythonException();
+ }
+}
+
+void
IcePy::LoggerWrapper::trace(const string& category, const string& message)
{
AdoptThread adoptThread; // Ensure the current thread is able to call into Python.
- cout << endl << "LoggerWrapper delegating to trace('" << category << "', '" << message << "')" << endl;
PyObjectHandle tmp = PyObject_CallMethod(_logger.get(), "trace", "ss", category.c_str(), message.c_str());
if(tmp.get() == NULL)
{
@@ -120,6 +132,33 @@ loggerDealloc(LoggerObject* self)
extern "C"
#endif
static PyObject*
+loggerPrint(LoggerObject* self, PyObject* args)
+{
+ char* message;
+ if(!PyArg_ParseTuple(args, "s", &message))
+ {
+ return NULL;
+ }
+
+ assert(self->logger);
+ try
+ {
+ (*self->logger)->print(message);
+ }
+ catch(const Ice::Exception& ex)
+ {
+ setPythonException(ex);
+ return NULL;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+#ifdef WIN32
+extern "C"
+#endif
+static PyObject*
loggerTrace(LoggerObject* self, PyObject* args)
{
char* category;
@@ -200,6 +239,8 @@ loggerError(LoggerObject* self, PyObject* args)
static PyMethodDef LoggerMethods[] =
{
+ { "_print", (PyCFunction)loggerPrint, METH_VARARGS,
+ PyDoc_STR("_print(message) -> None") },
{ "trace", (PyCFunction)loggerTrace, METH_VARARGS,
PyDoc_STR("trace(category, message) -> None") },
{ "warning", (PyCFunction)loggerWarning, METH_VARARGS,
@@ -255,7 +296,7 @@ PyTypeObject LoggerType =
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
- (newfunc)loggerNew, /* tp_new */
+ (newfunc)loggerNew, /* tp_new */
0, /* tp_free */
0, /* tp_is_gc */
};