diff --git a/esphome/components/logger/__init__.py b/esphome/components/logger/__init__.py index 88be43cb17..f5fc284294 100644 --- a/esphome/components/logger/__init__.py +++ b/esphome/components/logger/__init__.py @@ -324,7 +324,7 @@ CONFIG_SCHEMA = cv.All( ) -@coroutine_with_priority(CoroPriority.LOGGER_INIT) +@coroutine_with_priority(CoroPriority.EARLY_INIT) async def to_code(config: ConfigType) -> None: baud_rate: int = config[CONF_BAUD_RATE] level = config[CONF_LEVEL] diff --git a/esphome/coroutine.py b/esphome/coroutine.py index e6632d0c01..3ce94cc979 100644 --- a/esphome/coroutine.py +++ b/esphome/coroutine.py @@ -63,11 +63,11 @@ class CoroPriority(enum.IntEnum): resolution during code generation. """ - # Logger early init - must run before all other code because: - # 1. All code assumes global_logger is ready for ESP_LOG* calls - # 2. Without this, any log call before logger init dereferences nullptr + # Early init - runs before platform init and before Application exists. + # Currently used only to connect logging so ESP_LOG* calls work + # immediately in all subsequent phases. # Examples: logger (1100) - LOGGER_INIT = 1100 + EARLY_INIT = 1100 # Platform initialization # Examples: esp32, esp8266, rp2040