esp_log.h: How to exclude logging at compile time?
Posted: Sun Sep 25, 2022 7:13 am
(I submitted this issue to github a while ago but I thought this might be better asked here. https://github.com/espressif/esp-idf/issues/9851)
The documentation mentions that the logging level can be configured at compile time. I was expecting that the ESP_LOGx macro will be expanded to an empty statement if the level is not active, hence completely excluding it from the binary. But I am observing the macro to be expanded anyway and the filtering is done in runtime, adding to some overhead to process the code that should have been excluded from the build.
Below is the screenshot from my CLion IDE, My maximum log level was set to INFO but the verbose or debug level will still be expanded and compiled in my firmware.
Is this logging library working as expected? How could I prevent the verbose and debug logging from being compiled?
The documentation mentions that the logging level can be configured at compile time. I was expecting that the ESP_LOGx macro will be expanded to an empty statement if the level is not active, hence completely excluding it from the binary. But I am observing the macro to be expanded anyway and the filtering is done in runtime, adding to some overhead to process the code that should have been excluded from the build.
Below is the screenshot from my CLion IDE, My maximum log level was set to INFO but the verbose or debug level will still be expanded and compiled in my firmware.
Is this logging library working as expected? How could I prevent the verbose and debug logging from being compiled?