|
| 1 | +/* |
| 2 | + * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD |
| 3 | + * |
| 4 | + * SPDX-License-Identifier: Apache-2.0 |
| 5 | + */ |
| 6 | + |
| 7 | +#include "sdkconfig.h" |
| 8 | + |
| 9 | +/* |
| 10 | + * This file provides wrapper implementations for esp_log_write and esp_log_writev |
| 11 | + * when CONFIG_DIAG_USE_EXTERNAL_LOG_WRAP is not enabled. |
| 12 | + * |
| 13 | + * When CONFIG_DIAG_USE_EXTERNAL_LOG_WRAP is enabled, the esp_diagnostics component |
| 14 | + * provides these wrappers. However, when it's disabled, WiFi libraries still expect |
| 15 | + * these wrapper functions to exist, causing linker errors. |
| 16 | + * |
| 17 | + * This implementation provides simple pass-through wrappers that call the real |
| 18 | + * ESP-IDF logging functions, ensuring compatibility without requiring esp_diagnostics. |
| 19 | + */ |
| 20 | + |
| 21 | +#ifndef CONFIG_DIAG_USE_EXTERNAL_LOG_WRAP |
| 22 | + |
| 23 | +#include <stdarg.h> |
| 24 | +#include "esp_log_write.h" |
| 25 | + |
| 26 | +// Declare the real functions that will be wrapped |
| 27 | +void __real_esp_log_write(esp_log_level_t level, const char* tag, const char* format, ...); |
| 28 | +void __real_esp_log_writev(esp_log_level_t level, const char* tag, const char* format, va_list args); |
| 29 | + |
| 30 | +// Wrapper implementations that simply call through to the real functions |
| 31 | +void __wrap_esp_log_write(esp_log_level_t level, const char* tag, const char* format, ...) { |
| 32 | + va_list args; |
| 33 | + va_start(args, format); |
| 34 | + __real_esp_log_writev(level, tag, format, args); |
| 35 | + va_end(args); |
| 36 | +} |
| 37 | + |
| 38 | +void __wrap_esp_log_writev(esp_log_level_t level, const char* tag, const char* format, va_list args) { |
| 39 | + __real_esp_log_writev(level, tag, format, args); |
| 40 | +} |
| 41 | + |
| 42 | +#endif // !CONFIG_DIAG_USE_EXTERNAL_LOG_WRAP |
0 commit comments