[core] Fix startup delay from setup timing logs when console connected (#12832)

This commit is contained in:
J. Nick Koston
2026-01-03 12:32:10 -10:00
committed by GitHub
parent d505f0316b
commit 6685fa1da9

View File

@@ -205,7 +205,13 @@ void Component::call() {
this->call_setup();
#if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_DEBUG
uint32_t setup_time = millis() - start_time;
ESP_LOGCONFIG(TAG, "Setup %s took %ums", LOG_STR_ARG(this->get_component_log_str()), (unsigned) setup_time);
// Only log at CONFIG level if setup took longer than the blocking threshold
// to avoid spamming the log and blocking the event loop
if (setup_time >= WARN_IF_BLOCKING_OVER_MS) {
ESP_LOGCONFIG(TAG, "Setup %s took %ums", LOG_STR_ARG(this->get_component_log_str()), (unsigned) setup_time);
} else {
ESP_LOGV(TAG, "Setup %s took %ums", LOG_STR_ARG(this->get_component_log_str()), (unsigned) setup_time);
}
#endif
break;
}