Redirecting ESP Log output to file and back to USB serial

jmadsenee
Posts: 30
Joined: Tue Apr 19, 2022 1:16 am

Redirecting ESP Log output to file and back to USB serial

Postby jmadsenee » Sun Jan 15, 2023 5:47 pm

I am building a system that will have no USB serial connection most of the time and I want to re-direct stdout to a file on an SD card to store all of the logging messages. I am using:

Code: Select all

freopen(FileMonitorLog, "a", stdout);
to redirect stdout. Works great. Now at some point a USB connection may become available and I want to redirect stdout back to the USB serial port. What is the proper filename and mode to put into

Code: Select all

FILE *freopen(const char *filename, const char *mode, FILE *stream)
?

Thanks so much!

Who is online

Users browsing this forum: Google [Bot] and 102 guests