diff --git a/config/esp32/components/chip/Kconfig b/config/esp32/components/chip/Kconfig index 3b6d84a5c776fc..e92764e5dfa078 100644 --- a/config/esp32/components/chip/Kconfig +++ b/config/esp32/components/chip/Kconfig @@ -108,6 +108,14 @@ menu "CHIP Core" help Build CHIP test binaries. + config DISPATCH_EVENT_LONG_DISPATCH_TIME_WARNING_THRESHOLD_MS + int "Set threshold in ms" + default 700 + help + Time threshold for events dispatching. By default set to 0 to + to disable event dispatching time measurement and suppress the + logs for Long dispatch time. + # TODO: add log level selection endmenu # "General Options" diff --git a/src/platform/ESP32/CHIPPlatformConfig.h b/src/platform/ESP32/CHIPPlatformConfig.h index be023dfde901ae..9f7faedb8a0ff7 100644 --- a/src/platform/ESP32/CHIPPlatformConfig.h +++ b/src/platform/ESP32/CHIPPlatformConfig.h @@ -51,6 +51,7 @@ // The following values are configured via the ESP-IDF Kconfig mechanism. +#define CHIP_DISPATCH_EVENT_LONG_DISPATCH_TIME_WARNING_THRESHOLD_MS CONFIG_DISPATCH_EVENT_LONG_DISPATCH_TIME_WARNING_THRESHOLD_MS #define CHIP_CONFIG_MAX_UNSOLICITED_MESSAGE_HANDLERS CONFIG_MAX_UNSOLICITED_MESSAGE_HANDLERS #define CHIP_CONFIG_MAX_EXCHANGE_CONTEXTS CONFIG_MAX_EXCHANGE_CONTEXTS #define CHIP_CONFIG_SECURITY_TEST_MODE CONFIG_SECURITY_TEST_MODE diff --git a/src/platform/ESP32/Logging.cpp b/src/platform/ESP32/Logging.cpp index b2fbaac3cfbd1a..7f96a70dabecb2 100644 --- a/src/platform/ESP32/Logging.cpp +++ b/src/platform/ESP32/Logging.cpp @@ -26,20 +26,35 @@ void ENFORCE_FORMAT(3, 0) LogV(const char * module, uint8_t category, const char snprintf(tag, sizeof(tag), "chip[%s]", module); tag[sizeof(tag) - 1] = 0; - char formattedMsg[CHIP_CONFIG_LOG_MESSAGE_MAX_SIZE]; - vsnprintf(formattedMsg, sizeof(formattedMsg), msg, v); - switch (category) { case kLogCategory_Error: - ESP_LOGE(tag, "%s", formattedMsg); + if (esp_log_default_level >= ESP_LOG_ERROR) + { + printf(LOG_COLOR_E "E"); // set color + printf(" (%u) %s: ", esp_log_timestamp(), tag); // add timestamp + esp_log_writev(ESP_LOG_ERROR, tag, msg, v); + printf(LOG_RESET_COLOR "\n"); + } break; case kLogCategory_Progress: default: - ESP_LOGI(tag, "%s", formattedMsg); + if (esp_log_default_level >= ESP_LOG_INFO) + { + printf(LOG_COLOR_I "I"); // set color + printf(" (%u) %s: ", esp_log_timestamp(), tag); // add timestamp + esp_log_writev(ESP_LOG_INFO, tag, msg, v); + printf(LOG_RESET_COLOR "\n"); + } break; case kLogCategory_Detail: - ESP_LOGD(tag, "%s", formattedMsg); + if (esp_log_default_level >= ESP_LOG_DEBUG) + { + printf(LOG_COLOR_D "D"); // set color + printf(" (%u) %s: ", esp_log_timestamp(), tag); // add timestamp + esp_log_writev(ESP_LOG_DEBUG, tag, msg, v); + printf(LOG_RESET_COLOR "\n"); + } break; } }