From: Sven Trenkel Date: Mon, 12 Oct 2009 22:17:16 +0000 (+0200) Subject: Added logging. X-Git-Tag: collectd-4.9.0~35^2~33 X-Git-Url: https://git.octo.it/?a=commitdiff_plain;h=67b914e6f0f5e6c51c01716e520326348ff0e8aa;p=collectd.git Added logging. --- 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."},