From 3940f15cbcf628d123077ca4040b597586810d31 Mon Sep 17 00:00:00 2001 From: Terence Hampson Date: Thu, 27 Apr 2023 17:12:54 +0000 Subject: [PATCH 1/2] Revert parts of #26227 --- config/esp32/components/chip/Kconfig | 8 ++++---- src/platform/ESP32/Logging.cpp | 27 ++++++--------------------- 2 files changed, 10 insertions(+), 25 deletions(-) diff --git a/config/esp32/components/chip/Kconfig b/config/esp32/components/chip/Kconfig index e92764e5dfa078..c81d74a7d8fd9d 100644 --- a/config/esp32/components/chip/Kconfig +++ b/config/esp32/components/chip/Kconfig @@ -110,11 +110,11 @@ menu "CHIP Core" config DISPATCH_EVENT_LONG_DISPATCH_TIME_WARNING_THRESHOLD_MS int "Set threshold in ms" - default 700 + default 100 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. + Time threshold for warning that dispatched took too long. You can + set this default set to 0 to to disable event dispatching time + measurement and suppress the logs "Long dispatch time:...". # TODO: add log level selection diff --git a/src/platform/ESP32/Logging.cpp b/src/platform/ESP32/Logging.cpp index 7f96a70dabecb2..b2fbaac3cfbd1a 100644 --- a/src/platform/ESP32/Logging.cpp +++ b/src/platform/ESP32/Logging.cpp @@ -26,35 +26,20 @@ 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: - 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"); - } + ESP_LOGE(tag, "%s", formattedMsg); break; case kLogCategory_Progress: default: - 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"); - } + ESP_LOGI(tag, "%s", formattedMsg); break; case kLogCategory_Detail: - 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"); - } + ESP_LOGD(tag, "%s", formattedMsg); break; } } From 1de144a949dd76eeb95532c1573d8d21cf26a3a2 Mon Sep 17 00:00:00 2001 From: Terence Hampson Date: Fri, 28 Apr 2023 13:56:49 +0000 Subject: [PATCH 2/2] Address PR comment --- config/esp32/components/chip/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/esp32/components/chip/Kconfig b/config/esp32/components/chip/Kconfig index c81d74a7d8fd9d..077331b16cb3ef 100644 --- a/config/esp32/components/chip/Kconfig +++ b/config/esp32/components/chip/Kconfig @@ -110,7 +110,7 @@ menu "CHIP Core" config DISPATCH_EVENT_LONG_DISPATCH_TIME_WARNING_THRESHOLD_MS int "Set threshold in ms" - default 100 + default 700 help Time threshold for warning that dispatched took too long. You can set this default set to 0 to to disable event dispatching time