Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@xxxxxxxxx> --- src/ftracepy-utils.c | 23 +++++++++++++++++++++++ src/ftracepy-utils.h | 3 +++ src/ftracepy.c | 5 +++++ 3 files changed, 31 insertions(+) diff --git a/src/ftracepy-utils.c b/src/ftracepy-utils.c index dfb0669..8f4b50c 100644 --- a/src/ftracepy-utils.c +++ b/src/ftracepy-utils.c @@ -1801,6 +1801,29 @@ PyObject *PyFtrace_kprobe_is_enabled(PyObject *self, PyObject *args, return event_is_enabled(instance, TC_SYS, event); } +PyObject *PyFtrace_set_ftrace_loglevel(PyObject *self, PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = {"level", NULL}; + int level; + + if (!PyArg_ParseTupleAndKeywords(args, + kwargs, + "i", + kwlist, + &level)) { + return NULL; + } + + if (level < 0) + level = 0; + + tracefs_set_loglevel(level); + tep_set_loglevel(level); + + Py_RETURN_NONE; +} + static bool set_fork_options(struct tracefs_instance *instance, bool enable) { if (enable) { diff --git a/src/ftracepy-utils.h b/src/ftracepy-utils.h index d826427..5d7c19c 100644 --- a/src/ftracepy-utils.h +++ b/src/ftracepy-utils.h @@ -155,6 +155,9 @@ PyObject *PyFtrace_disable_kprobe(PyObject *self, PyObject *args, PyObject *PyFtrace_kprobe_is_enabled(PyObject *self, PyObject *args, PyObject *kwargs); +PyObject *PyFtrace_set_ftrace_loglevel(PyObject *self, PyObject *args, + PyObject *kwargs); + PyObject *PyFtrace_trace_process(PyObject *self, PyObject *args, PyObject *kwargs); diff --git a/src/ftracepy.c b/src/ftracepy.c index e5fcd54..e3fec7b 100644 --- a/src/ftracepy.c +++ b/src/ftracepy.c @@ -269,6 +269,11 @@ static PyMethodDef ftracepy_methods[] = { METH_VARARGS | METH_KEYWORDS, "Check if kprobe event is enabled." }, + {"set_ftrace_loglevel", + (PyCFunction) PyFtrace_set_ftrace_loglevel, + METH_VARARGS | METH_KEYWORDS, + "Set the verbose level of the ftrace libraries." + }, {"trace_process", (PyCFunction) PyFtrace_trace_process, METH_VARARGS | METH_KEYWORDS, -- 2.27.0