From 55e69bf9cb4dee2e20fbaae5b4e3d6a716f62a9f Mon Sep 17 00:00:00 2001 From: Jeff H Date: Sat, 16 Apr 2022 19:23:48 -0700 Subject: [PATCH] add option to route LWIP logs through ESP_LOG interface Signed-off-by: xueyunfei Merges https://github.com/espressif/esp-idf/pull/8785 Closes https://github.com/espressif/esp-idf/issues/8361 --- components/lwip/Kconfig | 7 +++++++ components/lwip/port/esp32/include/arch/cc.h | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/components/lwip/Kconfig b/components/lwip/Kconfig index e10947cdbd..1ad7a8b037 100644 --- a/components/lwip/Kconfig +++ b/components/lwip/Kconfig @@ -877,6 +877,13 @@ menu "LWIP" bool "Enable LWIP Debug" default n + config LWIP_DEBUG_ESP_LOG + bool "Route LWIP debugs through ESP_LOG interface" + depends on LWIP_DEBUG + default n + help + Enabling this option routes all enabled LWIP debugs through ESP_LOGD. + config LWIP_NETIF_DEBUG bool "Enable netif debug messages" depends on LWIP_DEBUG diff --git a/components/lwip/port/esp32/include/arch/cc.h b/components/lwip/port/esp32/include/arch/cc.h index 78935f3b5f..b0d6adca09 100644 --- a/components/lwip/port/esp32/include/arch/cc.h +++ b/components/lwip/port/esp32/include/arch/cc.h @@ -74,7 +74,15 @@ typedef int sys_prot_t; #include +#ifdef CONFIG_LWIP_DEBUG_ESP_LOG +// lwip debugs routed to ESP_LOGD +#include "esp_log.h" +#define LWIP_ESP_LOG_FUNC(format, ...) ESP_LOG_LEVEL(ESP_LOG_DEBUG, "lwip", format, ##__VA_ARGS__) +#define LWIP_PLATFORM_DIAG(x) LWIP_ESP_LOG_FUNC x +#else +// lwip debugs routed to printf #define LWIP_PLATFORM_DIAG(x) do {printf x;} while(0) +#endif #ifdef NDEBUG