From 67b914e6f0f5e6c51c01716e520326348ff0e8aa Mon Sep 17 00:00:00 2001 From: Sven Trenkel Date: Tue, 13 Oct 2009 00:17:16 +0200 Subject: [PATCH] Added logging. --- src/python.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/python.c b/src/python.c index a8f32b93..8d11d76b 100644 --- a/src/python.c +++ b/src/python.c @@ -196,7 +196,49 @@ static PyObject *cpy_register_shutdown(PyObject *self, PyObject *args, PyObject return cpy_register_generic(&cpy_shutdown_callbacks, args, kwds); } +static PyObject *cpy_Error(PyObject *self, PyObject *args) { + const char *text; + if (PyArg_ParseTuple(args, "s", &text) == 0) return NULL; + plugin_log(LOG_ERR, "%s", text); + Py_RETURN_NONE; +} + +static PyObject *cpy_Warning(PyObject *self, PyObject *args) { + const char *text; + if (PyArg_ParseTuple(args, "s", &text) == 0) return NULL; + plugin_log(LOG_WARNING, "%s", text); + Py_RETURN_NONE; +} + +static PyObject *cpy_Notice(PyObject *self, PyObject *args) { + const char *text; + if (PyArg_ParseTuple(args, "s", &text) == 0) return NULL; + plugin_log(LOG_NOTICE, "%s", text); + Py_RETURN_NONE; +} + +static PyObject *cpy_Info(PyObject *self, PyObject *args) { + const char *text; + if (PyArg_ParseTuple(args, "s", &text) == 0) return NULL; + plugin_log(LOG_INFO, "%s", text); + Py_RETURN_NONE; +} + +static PyObject *cpy_Debug(PyObject *self, PyObject *args) { +#ifdef COLLECT_DEBUG + const char *text; + if (PyArg_ParseTuple(args, "s", &text) == 0) return NULL; + plugin_log(LOG_DEBUG, "%s", text); +#endif + Py_RETURN_NONE; +} + static PyMethodDef cpy_methods[] = { + {"Debug", cpy_Debug, METH_VARARGS, "This is an unhelpful text."}, + {"Info", cpy_Info, METH_VARARGS, "This is an unhelpful text."}, + {"Notice", cpy_Notice, METH_VARARGS, "This is an unhelpful text."}, + {"Warning", cpy_Warning, METH_VARARGS, "This is an unhelpful text."}, + {"Error", cpy_Error, METH_VARARGS, "This is an unhelpful text."}, {"register_init", (PyCFunction) cpy_register_init, METH_VARARGS | METH_KEYWORDS, "This is an unhelpful text."}, {"register_config", (PyCFunction) cpy_register_config, METH_VARARGS | METH_KEYWORDS, "This is an unhelpful text."}, {"register_shutdown", (PyCFunction) cpy_register_shutdown, METH_VARARGS | METH_KEYWORDS, "This is an unhelpful text."}, -- 2.11.0