Filter out just printf statements

mhuszagh
Posts: 2
Joined: Tue Jun 08, 2021 9:57 pm

Filter out just printf statements

Postby mhuszagh » Fri Jul 16, 2021 2:13 pm

I'm calling printf in my application code to print data that I will later plot. I can redirect the output to a file with something like

Code: Select all

idf_monitor.py [...] > some_file
But, esp-idf prints a lot of other stuff to stdout, so the output is a bit polluted. Is there a way to filter out just the printf statements so that I can redirect just that information to a file?

I expect there would be a few ways to do this. One thought is it would be nice if esp-idf logged the info to stderr. Then I would still get those informational messages but the redirected stdout would contain just my print statements.

Another thought is that I wonder if I can achieve this with the logging facility. I looked at it a bit and tried out a few things but wasn't able to get what I was looking for.

Thoughts?

ESP_Sprite
Posts: 8926
Joined: Thu Nov 26, 2015 4:08 am

Re: Filter out just printf statements

Postby ESP_Sprite » Fri Jul 16, 2021 3:14 pm

Maybe a trivial answer, but the fastest:
printf("DATA: [whatever you want to print]\n');

and
idf_monitor.py | grep '^DATA:' | sed 's/^DATA://' > my_data.txt

The real answer would probably involve going into Menuconfig and turning off logging. That would still net you a little bit of startup chatter, and I think there's a GPIO you can pull up or down to get rid of that.

Who is online

Users browsing this forum: No registered users and 145 guests