Logging refactoring to supports macros redefinition and -D USE_ESP_IDF_LOG #281
+244
−121
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR refactors the logging layer of async_ws to give more flexibility to the developers and users
By default, the lib internally uses these variants for logging:
Each call is by forwarded to the framework under the hood: log_x for Arduino and Libretiny, ESP_LOGx for ESP-IDF, or when using Arduino with
-D USE_ESP_IDF_LOG
If the flag
-D ASYNCWEBSERVER_LOG_DEBUG
is set, the library switches in DEBUG mode and all the logs, regardless of their level, are sent to Serial output. This is useful for debug sessions.If the flag
-D ASYNCWEBSERVER_LOG_CUSTOM
is set, the user can provide in his projectAsyncWebServerLoggingCustom.h
header and has the ability to then define the macros / function like he wants.The library will now support
-D USE_ESP_IDF_LOG
and has its own tag:async_ws
, to useesp_log_level_set("async_ws", ESP_LOG_INFO);
Special notes for 8266 and PICO users:
ESP8266 and PICO do not provide a default logging framework to map our calls to, so we use under the hood
ets_printf
for 8266 andSerial.printf
for pico. You can then configure the logging level by using-D ASYNCWEBSERVER_LOG_LEVEL=<x>
where the levels can be:ASYNC_WS_LOG_NONE
ASYNC_WS_LOG_ERROR
ASYNC_WS_LOG_WARN
ASYNC_WS_LOG_INFO
ASYNC_WS_LOG_DEBUG
*/ASYNC_WS_LOG_VERBOSE
ASYNC_WS_LOG_MAX