Skip to content

Commit

Permalink
Fix pigweed RPC logging on ESP32 (#26282)
Browse files Browse the repository at this point in the history
  • Loading branch information
tehampson authored and pull[bot] committed Aug 25, 2023
1 parent da4b520 commit 91fca61
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 24 deletions.
6 changes: 3 additions & 3 deletions config/esp32/components/chip/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ menu "CHIP Core"
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.
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

Expand Down
27 changes: 6 additions & 21 deletions src/platform/ESP32/Logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down

0 comments on commit 91fca61

Please sign in to comment.