Saving debug log
Posted: Fri Feb 25, 2022 11:52 pm
I would like to reroute debug messages (those that normally go out to UART0 and are captured by a host terminal application on the other side) to a local SPIFFS file.
My understanding is that there are at least two ways of doing it:
Either by using printf() in the code and replacing stdout file descriptor with a spiffs file one,
Or by using IDF's ESP_LOGx() macros and using esp_log_set_vprintf() to replace vprintf() by another function that may finally use something like vfprintf to put the log data into the flash based log file.
One advantage of using ESP_LOGx() macros is that a module TAG is attached to a log line, but his is something that can easily be achieved creating a printf() based macro.
1. Please correct me if I'm wrong about this.
2. Which one of these two methods is better in terms of CPU and memory resources (time, stack space, heap use etc.).
Thank you.
My understanding is that there are at least two ways of doing it:
Either by using printf() in the code and replacing stdout file descriptor with a spiffs file one,
Or by using IDF's ESP_LOGx() macros and using esp_log_set_vprintf() to replace vprintf() by another function that may finally use something like vfprintf to put the log data into the flash based log file.
One advantage of using ESP_LOGx() macros is that a module TAG is attached to a log line, but his is something that can easily be achieved creating a printf() based macro.
1. Please correct me if I'm wrong about this.
2. Which one of these two methods is better in terms of CPU and memory resources (time, stack space, heap use etc.).
Thank you.