summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: df120b3)
raw | patch | inline | side by side (parent: df120b3)
author | Sven Trenkel <collectd@semidefinite.de> | |
Fri, 1 Jan 2010 21:16:51 +0000 (22:16 +0100) | ||
committer | Florian Forster <octo@noris.net> | |
Tue, 5 Jan 2010 10:03:12 +0000 (11:03 +0100) |
src/pyvalues.c | patch | blob | history |
diff --git a/src/pyvalues.c b/src/pyvalues.c
index c6b40321ae59a8aea76a63d59243db1a6ea5c3b7..3fb68cf21af49d12456b8299257c84c9fd2d7a37 100644 (file)
--- a/src/pyvalues.c
+++ b/src/pyvalues.c
@@ -826,19 +826,41 @@ static int Notification_setstring(PyObject *self, PyObject *value, void *data) {
return 0;
}
-/*static PyObject *Notification_repr(PyObject *s) {
- PyObject *ret;
+static PyObject *Notification_repr(PyObject *s) {
+ PyObject *ret, *tmp;
+ static PyObject *l_severity = NULL, *l_message = NULL, *l_closing = NULL;
Notification *self = (Notification *) s;
- ret = PyString_FromFormat("collectd.Values(type='%s%s%s%s%s%s%s%s%s%s%s',time=%lu,interval=%i)", self->data.type,
- *self->data.type_instance ? "',type_instance='" : "", self->data.type_instance,
- *self->data.plugin ? "',plugin='" : "", self->data.plugin,
- *self->data.plugin_instance ? "',plugin_instance='" : "", self->data.plugin_instance,
- *self->data.host ? "',host='" : "", self->data.host,
- *self->message ? "',message='" : "", self->message,
- (long unsigned) self->data.time, self->severity);
+ if (l_severity == NULL)
+ l_severity = cpy_string_to_unicode_or_bytes(",severity=");
+ if (l_message == NULL)
+ l_message = cpy_string_to_unicode_or_bytes(",message=");
+ if (l_closing == NULL)
+ l_closing = cpy_string_to_unicode_or_bytes(")");
+
+ if (l_severity == NULL || l_message == NULL || l_closing == NULL)
+ return NULL;
+
+ ret = cpy_common_repr(s);
+ if (self->severity != 0) {
+ CPY_SUBSTITUTE(CPY_STRCAT, ret, ret, l_severity);
+ tmp = PyInt_FromLong(self->severity);
+ CPY_SUBSTITUTE(PyObject_Repr, tmp, tmp);
+ if (tmp)
+ CPY_SUBSTITUTE(CPY_STRCAT, ret, ret, tmp);
+ Py_XDECREF(tmp);
+ }
+ if (self->message[0] != 0) {
+ CPY_SUBSTITUTE(CPY_STRCAT, ret, ret, l_message);
+ tmp = cpy_string_to_unicode_or_bytes(self->message);
+ CPY_SUBSTITUTE(PyObject_Repr, tmp, tmp);
+ if (tmp)
+ CPY_SUBSTITUTE(CPY_STRCAT, ret, ret, tmp);
+ Py_XDECREF(tmp);
+ }
+ CPY_SUBSTITUTE(CPY_STRCAT, ret, ret, l_closing);
return ret;
-}*/
+}
static PyMethodDef Notification_methods[] = {
{"dispatch", (PyCFunction) Notification_dispatch, METH_VARARGS | METH_KEYWORDS, dispatch_doc},
0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_compare */
- 0/*Notification_repr*/, /* tp_repr */
+ Notification_repr, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */