diff options
-rw-r--r-- | README.md | 10 | ||||
-rw-r--r-- | journald.c | 34 | ||||
-rw-r--r-- | setup.py | 9 |
3 files changed, 52 insertions, 1 deletions
@@ -1,4 +1,12 @@ journald-python =============== -Python module for native access to systemd's journald facilities
\ No newline at end of file +Python module for native access to systemd's journald facilities + +Installation +============ + +On Fedora 17: + +sudo yum install git python-pip gcc python-devel systemd-devel +pip-python git+http://github.com/davidstrauss/journald-python.git#egg=journald diff --git a/journald.c b/journald.c new file mode 100644 index 0000000..5f9d41b --- /dev/null +++ b/journald.c @@ -0,0 +1,34 @@ +#include <Python.h> +#include <systemd/sd-journal.h> + +#ifndef journaldpython +#define journaldpython + +static PyObject * +journald_send(PyObject *self, PyObject *args) +{ + //const char *command; + //int sts; + + //if (!PyArg_ParseTuple(args, "s", &command)) + // return NULL; + //sts = system(command); + //return Py_BuildValue("i", sts); + sd_journal_send("Test message: %s.", "arg1", NULL); + Py_INCREF(Py_None); + return Py_None; +} + +static PyMethodDef journaldMethods[] = { + {"send", journald_send, METH_VARARGS, + "Send an entry to journald."}, + {NULL, NULL, 0, NULL} /* Sentinel */ +}; + +PyMODINIT_FUNC +initjournal(void) +{ + (void) Py_InitModule("journald", journaldMethods); +} + +#endif diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..ba34a4b --- /dev/null +++ b/setup.py @@ -0,0 +1,9 @@ +from distutils.core import setup, Extension + +journald = Extension('journald', + sources = ['journald.c']) + +setup (name = 'journald', + version = '0.1', + description = 'Native interface to the journald facilities of systemd', + ext_modules = [journald]) |