It seems that
build_flags = -DCORE_DEBUG_LEVEL=x
in file platformio.ini does NOT affect “C” source files, only “CPP” ones.
In my IDE (see details at the end) it seems that ony “E” level are shown in “C” files. If you use LOGV it won’t be seen evend configuring DCORE_DEBUG_LEVEL=5
In CPP files all is fine.
#include "Arduino.h"
extern "C" {
void test_log_c(); /* from test.c */
}
void setup()
{
printf("Start of firmware\n");
log_i("Test log level information from C++");
log_v("Test log level verbose from C++");
test_log_c();
}
void loop()
{
}
and src/test.c
#include <esp32-hal-log.h>
void test_log_c() {
log_i("Test log level information from C");
log_v("Test log level verbose from C");
}
as one can see in the execution log
Start of firmware
[I][main.cpp:10] setup(): Test log level information from C++
[I][test.c:4] test_log_c(): Test log level information from C
there is no difference between C and C++ files, both behave the same. Info logs go through while debug and verbose logs don’t, since they’re compile-time removed.
Through a “Verbose Build”, one can also see that both compiler invocations have the -DCORE_DEBUG_LEVEL=3 flag.
I was using “esp_log.h” and the macros ESP_LOGx ESP_LOGE(TAG, "LOGE test"); ESP_LOGW(TAG, "LOGW test"); ESP_LOGI(TAG, "LOGI test"); ESP_LOGD(TAG, "LOGD test"); ESP_LOGV(TAG, "LOGV test");
And indepently of platformio.ini, only ESP_LOGE was be seen on the monitor port: E (170) Touch pad: LOGE test
BUT, if I maintain the previous macros and add yours… log_e("log_e test"); log_w("log_w test"); log_i("log_i test"); log_d("log_d test"); log_v("log_v test");
I can see all the logs (ESP_LOGx and log_x): [E][touchpad.c:80] initializeTouchPad(): LOGE test [W][touchpad.c:81] initializeTouchPad(): LOGW test [I][touchpad.c:82] initializeTouchPad(): LOGI test [E][touchpad.c:87] initializeTouchPad(): log_e test [W][touchpad.c:88] initializeTouchPad(): log_w test [I][touchpad.c:89] initializeTouchPad(): log_i test
As you can see the ESP_LOGx syntax is lost (TAG not shown).
Anyway, thanks for your help, I will use log_x and the #include <esp32-hal-log.h>
instead of #include “esp_log.h”
That file does get included by esp32-hal-log.h though
And those same macros are available, and should behave the same. esp_log.h seems to be the low-level component that does the actual logging, but esp32-hal-log.h is one layer above and compile-time deactivates those macros or functions.