Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pigweed RPC logging on ESP32 #26282

Merged
merged 2 commits into from
Apr 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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];
tehampson marked this conversation as resolved.
Show resolved Hide resolved
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);
tehampson marked this conversation as resolved.
Show resolved Hide resolved
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