cakira wrote: ↑Thu Jan 21, 2021 6:23 pm
Most of the time I use platform IO, but as my colleagues use the Arduino IDE, I had the same problem described here.
My solution was to include in the very begining of the .ino file, before the includes:
Code: Select all
#ifdef CORE_DEBUG_LEVEL
#undef CORE_DEBUG_LEVEL
#endif
#define CORE_DEBUG_LEVEL 3
#define LOG_LOCAL_LEVEL ESP_LOG_DEBUG
I'm not sure the last define is necessary, but anyway,
Code: Select all
ESP_LOGI(TAG, "Read: %s", message);
is working and printing:
[I][EspFile.ino:240] loop(): Read: 23;33.19;-5;-119;32.25;36, as I intended.
Thank you cakira. Can confirm that the last define is needed. Might also want to
undef LOG_LOCAL_LEVEL to avoid compiler warnings. Here is how I set the log level to debug (4).
Code: Select all
#if (!PLATFORMIO)
// Enable Arduino-ESP32 logging in Arduino IDE
#ifdef CORE_DEBUG_LEVEL
#undef CORE_DEBUG_LEVEL
#endif
#ifdef LOG_LOCAL_LEVEL
#undef LOG_LOCAL_LEVEL
#endif
#define CORE_DEBUG_LEVEL 4
#define LOG_LOCAL_LEVEL CORE_DEBUG_LEVEL
#endif
#include <esp32-hal-log.h>
...
void setup()
{
Serial.begin(115200);
delay(10000);
Serial.printf("LOG_LOCAL_LEVEL %d\n", LOG_LOCAL_LEVEL);
// esp32-hal-log.h esp_log.h
// level 0 = ARDUHAL_LOG_LEVEL_NONE = ESP_LOG_NONE
ESP_LOGE(TAG, "ESP_LOGE, level 1 = ARDUHAL_LOG_LEVEL_ERROR = ESP_LOG_ERROR");
ESP_LOGW(TAG, "ESP_LOGW, level 2 = ARDUHAL_LOG_LEVEL_WARN = ESP_LOG_WARN");
ESP_LOGI(TAG, "ESP_LOGI, level 3 = ARDUHAL_LOG_LEVEL_INFO = ESP_LOG_INFO");
ESP_LOGD(TAG, "ESP_LOGD, level 4 = ARDUHAL_LOG_LEVEL_DEBUG = ESP_LOG_DEBUG");
ESP_LOGV(TAG, "ESP_LOGV, level 5 = ARDUHAL_LOG_LEVEL_VERBOSE = ESP_LOG_VERBOSE");
...
The last
ESP_LOGV(...) is not printed because verbose (5) > debug (4). These settings are local only and
#define CORE_DEBUB_LEVEL 4 has no effect on the debug level of the core. As felix41382/Neil Kolban pointed out, the output of log messages from the core is determined by the
Core debug level set in with
Tools in the IDE.
If anyone is wondering, doing the same in PlatformIO requires adding an
env build flag in the platformio.ini:
Code: Select all
[env:seeed_xiao_esp32c3]
board = seeed_xiao_esp32c3
framework = arduino
; Enable ArduinoESP32 logging
build_flags = -DCORE_DEBUG_LEVEL=4 ; Clean project after changing the level
...
However that sets the log level for both the core and the current project.