-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.");
-static PyObject *
-Journal_this_boot(Journal *self, PyObject *args)
-{
- sd_id128_t sd_id;
- int r;
- r = sd_id128_get_boot(&sd_id);
- if (r == -EIO) {
- PyErr_SetString(PyExc_IOError, "Error getting current boot ID");
- return NULL;
- } else if (r < 0) {
- PyErr_SetString(PyExc_RuntimeError, "Error getting current boot ID");
- return NULL;
- }
-
- char bootid[33];
- sd_id128_to_string(sd_id, bootid);
-
- PyObject *arg, *keywds;
- arg = PyTuple_New(0);
- keywds = Py_BuildValue("{s:s}", "_BOOT_ID", bootid);
- Journal_add_match(self, arg, keywds);
- Py_DECREF(arg);
- Py_DECREF(keywds);
- if (PyErr_Occurred())
- return NULL;
-
- Py_RETURN_NONE;
-}
-
-PyDoc_STRVAR(Journal_this_machine__doc__,
-"this_machine() -> None\n\n"
-"Sets match filter for the current _MACHINE_ID.");
-static PyObject *
-Journal_this_machine(Journal *self, PyObject *args)
-{
- sd_id128_t sd_id;
- int r;
- r = sd_id128_get_machine(&sd_id);
- if (r == -EIO) {
- PyErr_SetString(PyExc_IOError, "Error getting current boot ID");
- return NULL;
- } else if (r < 0) {
- PyErr_SetString(PyExc_RuntimeError, "Error getting current boot ID");
- return NULL;
- }
-
- char machineid[33];
- sd_id128_to_string(sd_id, machineid);
-
- PyObject *arg, *keywds;
- arg = PyTuple_New(0);
- keywds = Py_BuildValue("{s:s}", "_MACHINE_ID", machineid);
- Journal_add_match(self, arg, keywds);
- Py_DECREF(arg);
- Py_DECREF(keywds);
- if (PyErr_Occurred())
- return NULL;
-
- Py_RETURN_NONE;
-}
-
-static PyObject *
-Journal_get_default_call(Journal *self, void *closure)
-{
- Py_INCREF(self->default_call);
- return self->default_call;
-}
-
-static int
-Journal_set_default_call(Journal *self, PyObject *value, void *closure)
-{
- if (value == NULL) {
- PyErr_SetString(PyExc_TypeError, "Cannot delete default_call");
- return -1;
- }
- if (! PyCallable_Check(value)) {
- PyErr_SetString(PyExc_TypeError, "default_call must be callable");
- return -1;
- }
- Py_DECREF(self->default_call);
- Py_INCREF(value);
- self->default_call = value;
-
- return 0;
-}
-
-static PyObject *
-Journal_get_call_dict(Journal *self, void *closure)
-{
- Py_INCREF(self->call_dict);
- return self->call_dict;
-}
-
-static int
-Journal_set_call_dict(Journal *self, PyObject *value, void *closure)
-{
- if (value == NULL) {
- PyErr_SetString(PyExc_TypeError, "Cannot delete call_dict");
- return -1;
- }
- if (! PyDict_Check(value)) {
- PyErr_SetString(PyExc_TypeError, "call_dict must be dict type");
- return -1;
- }
- Py_DECREF(self->call_dict);
- Py_INCREF(value);
- self->call_dict = value;
-
- return 0;
-}
-