Skip to content

Commit fa570cc

Browse files
authored
Revert "esp32-fix-empty-logs(#35939)" (#36035)
* Revert "esp32-fix-empty-logs(#35939) (#35965)" This reverts commit 2a19f57. * Add comment explaining why printf is used
1 parent cc50e9e commit fa570cc

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/platform/ESP32/Logging.cpp

+9-6
Original file line numberDiff line numberDiff line change
@@ -25,32 +25,35 @@ void LogV(const char * module, uint8_t category, const char * msg, va_list v)
2525
snprintf(tag, sizeof(tag), "chip[%s]", module);
2626
tag[sizeof(tag) - 1] = 0;
2727

28+
// We intentionally added the printf statements to ensure we could apply colors to logs redirected to the console.
29+
// The printf statements are not bypassing the log level, rather, they are intentionally designed to print the
30+
// initial and later parts of the log.
2831
switch (category)
2932
{
3033
case kLogCategory_Error: {
3134
{
32-
esp_log_write(ESP_LOG_ERROR, tag, LOG_COLOR_E "E (%" PRIu32 ") %s: ", esp_log_timestamp(), tag);
35+
printf(LOG_COLOR_E "E (%" PRIu32 ") %s: ", esp_log_timestamp(), tag);
3336
esp_log_writev(ESP_LOG_ERROR, tag, msg, v);
34-
esp_log_write(ESP_LOG_ERROR, tag, LOG_RESET_COLOR "\n");
37+
printf(LOG_RESET_COLOR "\n");
3538
}
3639
}
3740
break;
3841

3942
case kLogCategory_Progress:
4043
default: {
4144
{
42-
esp_log_write(ESP_LOG_INFO, tag, LOG_COLOR_I "I (%" PRIu32 ") %s: ", esp_log_timestamp(), tag);
45+
printf(LOG_COLOR_I "I (%" PRIu32 ") %s: ", esp_log_timestamp(), tag);
4346
esp_log_writev(ESP_LOG_INFO, tag, msg, v);
44-
esp_log_write(ESP_LOG_INFO, tag, LOG_RESET_COLOR "\n");
47+
printf(LOG_RESET_COLOR "\n");
4548
}
4649
}
4750
break;
4851

4952
case kLogCategory_Detail: {
5053
{
51-
esp_log_write(ESP_LOG_DEBUG, tag, LOG_COLOR_D "D (%" PRIu32 ") %s: ", esp_log_timestamp(), tag);
54+
printf(LOG_COLOR_D "D (%" PRIu32 ") %s: ", esp_log_timestamp(), tag);
5255
esp_log_writev(ESP_LOG_DEBUG, tag, msg, v);
53-
esp_log_write(ESP_LOG_DEBUG, tag, LOG_RESET_COLOR "\n");
56+
printf(LOG_RESET_COLOR "\n");
5457
}
5558
}
5659
break;

0 commit comments

Comments
 (0)