_journal.c revision 8d7e170a5230753d8406276f8b5598e5bb6766e6
#include <Python.h>
#define SD_JOURNAL_SUPPRESS_LOCATION
#include <systemd/sd-journal.h>
#include "macro.h"
"sendv('FIELD=value', 'FIELD=value', ...) -> None\n\n"
"Send an entry to the journal."
);
static PyObject *
int i, r;
if (!encoded) {
ret = PyErr_NoMemory();
goto out1;
}
// Allocate sufficient iovector space for the arguments.
if (!iov) {
ret = PyErr_NoMemory();
goto out;
}
// Iterate through the Python arguments and fill the iovector.
for (i = 0; i < argc; ++i) {
char *stritem;
if (PyUnicode_Check(item)) {
goto out;
}
goto out;
}
// Clear errno, because sd_journal_sendv will not set it by
// itself, unless an error occurs in one of the system calls.
errno = 0;
// Send the iovector to the journal.
if (r) {
if (errno)
else
goto out;
}
// End with success.
out:
for (i = 0; i < argc; ++i)
Py_XDECREF(encoded[i]);
out1:
// Free the iovector. The actual strings
// are already managed by Python.
return ret;
}
"stream_fd(identifier, priority, level_prefix) -> fd\n\n"
"Open a stream to journal by calling sd_journal_stream_fd(3)."
);
static PyObject*
const char* identifier;
int priority, level_prefix;
int fd;
return NULL;
if (fd < 0)
return PyErr_SetFromErrno(PyExc_IOError);
return PyLong_FromLong(fd);
}
static PyMethodDef methods[] = {
};
#if PY_MAJOR_VERSION < 3
init_journal(void)
{
}
#else
static struct PyModuleDef module = {
"_journal", /* name of module */
NULL, /* module documentation, may be NULL */
0, /* size of per-interpreter state of the module */
};
PyInit__journal(void)
{
return PyModule_Create(&module);
}
#endif