Our ESP32 WROVER application is a multitasking one and it is using NewLib. We have 16MG of flash, so we decided to use half of it for a debug log file, using spifFS.
Instead of using vprintf redirection, we use fprintf(), where we change the file pointer to either stdio or to a log file pointer. It mostly works well.
Similar to IDF, we have various log levels and the macro for this is:
Code: Select all
#define EIM_DBG_E(...) {\
if (DBG_LVL >= DBG_LVL_E) \
{ \
fprintf(fpCurOutFile, "E: %s: ", TAG); \
fprintf(fpCurOutFile, __VA_ARGS__); \
} \
}
When everything is slow, at some point we even start getting exceptions in newlib, which disappear once debug level is set to E(rror).
It looks like the main reason for this is the usage of fprintf() for logging although I still don’t understand how come it is initially all OK and all of a sudden it becomes very slow. I just wanted to ask if fprintf() is really the reason and if there is there that can be done about this. Is fprinf() implementation safe to be used in the multitasking environment or should we rather go back and use esp_log_set_vprintf().
Thank you.