Skip to content

Conversation

mathieucarbou
Copy link
Member

@mathieucarbou mathieucarbou commented Sep 9, 2025

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:

  • async_ws_log_e
  • async_ws_log_w
  • async_ws_log_i
  • async_ws_log_d
  • async_ws_log_v (for dev traces)

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 project AsyncWebServerLoggingCustom.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 use esp_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 and Serial.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

Copilot

This comment was marked as outdated.

@mathieucarbou mathieucarbou force-pushed the logging branch 2 times, most recently from 6764f2b to d4e930f Compare September 9, 2025 22:47
Copilot

This comment was marked as outdated.

@mathieucarbou mathieucarbou changed the title Logging refactoring to supports macros redefinition and -D USE_ESP_IFG_LOG Logging refactoring to supports macros redefinition and -D USE_ESP_IDF_LOG Sep 9, 2025
Copilot

This comment was marked as outdated.

Copilot

This comment was marked as duplicate.

@mathieucarbou mathieucarbou force-pushed the logging branch 6 times, most recently from 7035242 to 271e3f5 Compare September 10, 2025 09:35
@mathieucarbou mathieucarbou merged commit 250d76a into main Sep 16, 2025
35 checks passed
@mathieucarbou mathieucarbou deleted the logging branch September 16, 2025 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants