]> git.ipfire.org Git - people/ms/libloc.git/commitdiff
python: Add function to set log level
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 1 Feb 2018 11:54:01 +0000 (11:54 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 1 Feb 2018 11:54:01 +0000 (11:54 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/python/locationmodule.c

index 03e4cf55c394569497761befa9aa0ef49c74991c..40b0c35ffb032d4e2cf1a917437580bdec17659e 100644 (file)
@@ -15,6 +15,7 @@
 */
 
 #include <Python.h>
 */
 
 #include <Python.h>
+#include <syslog.h>
 
 #include "locationmodule.h"
 #include "as.h"
 
 #include "locationmodule.h"
 #include "as.h"
@@ -30,7 +31,24 @@ static void location_free(void) {
                loc_unref(loc_ctx);
 }
 
                loc_unref(loc_ctx);
 }
 
+static PyObject* set_log_level(PyObject* m, PyObject* args) {
+       int priority = LOG_INFO;
+
+       if (!PyArg_ParseTuple(args, "i", &priority))
+               return NULL;
+
+       loc_set_log_priority(loc_ctx, priority);
+
+       Py_RETURN_NONE;
+}
+
 static PyMethodDef location_module_methods[] = {
 static PyMethodDef location_module_methods[] = {
+       {
+               "set_log_level",
+               (PyCFunction)set_log_level,
+               METH_VARARGS,
+               NULL,
+       },
        { NULL },
 };
 
        { NULL },
 };