summaryrefslogtreecommitdiff
path: root/journald.c
blob: 5f9d41b44064f8f43c4b48b178dc498498222684 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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