summaryrefslogtreecommitdiff
path: root/src/python-systemd
diff options
context:
space:
mode:
authorSteven Hiscocks <steven@hiscocks.me.uk>2013-02-15 17:09:47 +0000
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-02-22 16:57:43 +0100
commit25523db4e1a3da09916ed69c1e90a52d027ac765 (patch)
tree2125a7911ee078d2326752fdcc771f6d36915672 /src/python-systemd
parentc1db45c6a5b0bd2ad7ddbfd877162794ac3a48f8 (diff)
systemd-python: Journal log_level moved to python
Diffstat (limited to 'src/python-systemd')
-rw-r--r--src/python-systemd/_reader.c32
-rw-r--r--src/python-systemd/journal.py8
2 files changed, 8 insertions, 32 deletions
diff --git a/src/python-systemd/_reader.c b/src/python-systemd/_reader.c
index f047ab9e6d..ce6631782f 100644
--- a/src/python-systemd/_reader.c
+++ b/src/python-systemd/_reader.c
@@ -671,36 +671,6 @@ Journal_query_unique(Journal *self, PyObject *args)
}
#endif //def SD_JOURNAL_FOREACH_UNIQUE
-PyDoc_STRVAR(Journal_log_level__doc__,
-"log_level(level) -> None\n\n"
-"Sets maximum log level by setting matches for PRIORITY.");
-static PyObject *
-Journal_log_level(Journal *self, PyObject *args)
-{
- int level;
- if (! PyArg_ParseTuple(args, "i", &level))
- return NULL;
-
- if (level < 0 || level > 7) {
- PyErr_SetString(PyExc_ValueError, "Log level should be 0 <= level <= 7");
- return NULL;
- }
- int i;
- char level_str[2];
- PyObject *arg, *keywds;
- for(i = 0; i <= level; i++) {
- sprintf(level_str, "%i", i);
- arg = PyTuple_New(0);
- keywds = Py_BuildValue("{s:s}", "PRIORITY", level_str);
- Journal_add_match(self, arg, keywds);
- Py_DECREF(arg);
- Py_DECREF(keywds);
- if (PyErr_Occurred())
- return NULL;
- }
- Py_RETURN_NONE;
-}
-
PyDoc_STRVAR(Journal_this_boot__doc__,
"this_boot() -> None\n\n"
"Sets match filter for the current _BOOT_ID.");
@@ -848,8 +818,6 @@ static PyMethodDef Journal_methods[] = {
{"query_unique", (PyCFunction)Journal_query_unique, METH_VARARGS,
Journal_query_unique__doc__},
#endif
- {"log_level", (PyCFunction)Journal_log_level, METH_VARARGS,
- Journal_log_level__doc__},
{"this_boot", (PyCFunction)Journal_this_boot, METH_NOARGS,
Journal_this_boot__doc__},
{"this_machine", (PyCFunction)Journal_this_machine, METH_NOARGS,
diff --git a/src/python-systemd/journal.py b/src/python-systemd/journal.py
index 8a688f978b..40e40c360b 100644
--- a/src/python-systemd/journal.py
+++ b/src/python-systemd/journal.py
@@ -115,6 +115,14 @@ class Journal(_Journal):
return set(self._convert_field(key, value)
for value in super(Journal, self).query_unique(key, *args, **kwargs))
+ def log_level(self, level):
+ """Sets maximum log level by setting matches for PRIORITY."""
+ if 0 <= level <= 7:
+ for i in range(level+1):
+ self.add_match(PRIORITY="%s" % i)
+ else:
+ raise ValueError("Log level must be 0 <= level <= 7")
+
def _make_line(field, value):
if isinstance(value, bytes):
return field.encode('utf-8') + b'=' + value