Skip to content

Commit

Permalink
Suppressing the logs related to events' Long dispatch time and Log re…
Browse files Browse the repository at this point in the history
…lated changes in Logging.cpp. (#26227)

-Provided the config option specific to ESP32 to set the threshold for events dispatching time.
-Set the config option by default to 0 to suppress the Long dispatch time logs.
-The log related changes mainly changes the way the logs are converted into the idf specific format.
-The arguments are directly used from chip_log instead of converting them to a string and then calling the IDF API.
-This also removes the need for the extra buffer, and also removes the limit for the 256 length for the log + arguments
size.
  • Loading branch information
shripad621git authored and pull[bot] committed Oct 29, 2024
1 parent ba8bb4c commit 1119711
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
8 changes: 8 additions & 0 deletions config/esp32/components/chip/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions src/platform/ESP32/CHIPPlatformConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 21 additions & 6 deletions src/platform/ESP32/Logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down

0 comments on commit 1119711

Please sign in to comment.