diff mbox series

[1/4] trace-cruncher: Add set_ftrace_loglevel()

Message ID 20210712123242.223500-1-y.karadz@gmail.com (mailing list archive)
State Accepted
Headers show
Series [1/4] trace-cruncher: Add set_ftrace_loglevel() | expand

Commit Message

Yordan Karadzhov July 12, 2021, 12:32 p.m. UTC
Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
---
 src/ftracepy-utils.c | 23 +++++++++++++++++++++++
 src/ftracepy-utils.h |  3 +++
 src/ftracepy.c       |  5 +++++
 3 files changed, 31 insertions(+)

Comments

Steven Rostedt July 22, 2021, 9:15 p.m. UTC | #1
On Mon, 12 Jul 2021 15:32:39 +0300
"Yordan Karadzhov (VMware)" <y.karadz@gmail.com> wrote:

-ENOCOMMITMESSAGE

Please describe what you are doing and why. The subject is not enough.

Even on simple changes, there should be some commentary.

The rest looks fine.

-- Steve


> Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
> ---
>  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,
Yordan Karadzhov July 26, 2021, 9:34 a.m. UTC | #2
On 23.07.21 г. 0:15, Steven Rostedt wrote:
> On Mon, 12 Jul 2021 15:32:39 +0300
> "Yordan Karadzhov (VMware)" <y.karadz@gmail.com> wrote:
> 
> -ENOCOMMITMESSAGE
> 
> Please describe what you are doing and why. The subject is not enough.
> 
> Even on simple changes, there should be some commentary.

There was a message for this commit. I guess I somehow deleted it with 
the last rebase. Will fix this in v2.

Thanks!
Yordan

> The rest looks fine.
> 
> -- Steve
> 
> 
>> Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
>> ---
>>   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,
>
diff mbox series

Patch

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,