diff --git a/examples/platform/esp32/PigweedLogger.cpp b/examples/platform/esp32/PigweedLogger.cpp index 84140f580e90fb..39851850bfa34c 100644 --- a/examples/platform/esp32/PigweedLogger.cpp +++ b/examples/platform/esp32/PigweedLogger.cpp @@ -90,8 +90,9 @@ extern "C" void __wrap_esp_log_write(esp_log_level_t level, const char * tag, co { va_list v; va_start(v, format); + #ifndef CONFIG_LOG_DEFAULT_LEVEL_NONE - if (uartInitialised) + if (uartInitialised && level <= CONFIG_LOG_MAXIMUM_LEVEL) { char formattedMsg[CHIP_CONFIG_LOG_MESSAGE_MAX_SIZE]; size_t len = vsnprintf(formattedMsg, sizeof formattedMsg, format, v); @@ -102,6 +103,7 @@ extern "C" void __wrap_esp_log_write(esp_log_level_t level, const char * tag, co PigweedLogger::putString(formattedMsg, len); } #endif + va_end(v); }