Description
Hardware
Board: ESP32 Dev Module
Core Installation version: tested on master (v2.0.1) - part of the problem dates back to April so not new
IDE name: Platform.io on VSCode
Flash Frequency: 40Mhz
PSRAM enabled: no PSRAM
Upload Speed: 921600
Computer OS: Ubuntu
Description
The system logs were reviewed to allow access to the ESP functions so that they can be rerouted (and not just use the terminal as output).
I will refer to the post I made on a PR recently because it may fall through the cracks (it was merged a while ago):
Hi, thanks for addressing this. I found a couple of issues
@jfbuggen
- there is a bug on line 161 which breaks compilation if log levels are set to ERROR or higher:
#define log_e(format, ...) do {log_to_esp(TAG, ESP_LOG_ERROR, format, ##__VA_ARGS__);}while(0)
should be changed to
#define log_e(format, ...) do {ESP_LOG_LEVEL_LOCAL(ESP_LOG_ERROR, TAG, format, ##__VA_ARGS__);}while(0)
[Note: it seems to have been right at the time of PR but somehow broken afterwards]
-
Also, not sure why the ARDUHAL_LOG_LEVEL_NONE is formatted as ARDUHAL_LOG_LEVEL_ERROR . Perhaps not an issue but intentional?
-
Main issue Added possibility to use ESP32-IDF log insted of redefined one #4845 was trying to address is ability to use ESP log instead of Arduino so that esp_log_set_vprintf could be used. This is now broken. Not 100% sure it is due to this change or something else in IDF functions? See below:
Example code flow:
//function used to reroute the logs
int websocket_printf(char * message, va_list args)
{
//Serial.printf("%s\r\n", message); //this line is commented but the system crashes anyway
}
esp_log_level_set("*", ESP_LOG_ERROR);
esp_log_set_vprintf((vprintf_like_t)&websocket_printf);
log_e("%s\r\n", "hi");
This results in the following error
0x4014b063:0x3ffb27500 in s_log_level_get_and_unlock at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/log/log.c:162
If the esp_log_set_vprintf() line is commented out then the logs work via serial normally (if point 1. above is fixed first)
Originally posted by @coratron in #5081 (comment)