_journal.c revision 5afbe712db5cc68213a24c45396ffb43fab05e3e
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2012 David Strauss <david@davidstrauss.net>
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <Python.h>
#include <alloca.h>
#define SD_JOURNAL_SUPPRESS_LOCATION
#include <systemd/sd-journal.h>
"sendv('FIELD=value', 'FIELD=value', ...) -> None\n\n"
"Send an entry to the journal."
);
int argc;
int i, r;
/* Allocate an array for the argument strings */
/* Allocate sufficient iovector space for the arguments. */
/* 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;
}
/* Send the iovector to the journal. */
if (r < 0) {
errno = -r;
goto out;
}
/* End with success. */
out:
for (i = 0; i < argc; ++i)
Py_XDECREF(encoded[i]);
return ret;
}
"stream_fd(identifier, priority, level_prefix) -> fd\n\n"
"Open a stream to journal by calling sd_journal_stream_fd(3)."
);
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
PyMODINIT_FUNC init_journal(void) {
PyObject *m;
if (m == NULL)
return;
}
#else
static struct PyModuleDef module = {
"_journal", /* name of module */
NULL, /* module documentation, may be NULL */
-1, /* size of per-interpreter state of the module */
};
PyMODINIT_FUNC PyInit__journal(void) {
PyObject *m;
m = PyModule_Create(&module);
if (m == NULL)
return NULL;
Py_DECREF(m);
return NULL;
}
return m;
}
#endif