diff --git a/esphome/components/logger/logger.cpp b/esphome/components/logger/logger.cpp index eaaf312ba9..5dedf33625 100644 --- a/esphome/components/logger/logger.cpp +++ b/esphome/components/logger/logger.cpp @@ -171,7 +171,7 @@ void Logger::init_log_buffer(size_t total_buffer_size) { this->log_buffer_ = new logger::TaskLogBuffer(total_buffer_size); // Zephyr needs loop working to check when CDC port is open -#if defined(USE_ESP32) || defined(USE_LIBRETINY) && !(defined(USE_ZEPHYR) || defined(USE_LOGGER_USB_CDC)) +#if !(defined(USE_ZEPHYR) || defined(USE_LOGGER_USB_CDC)) // Start with loop disabled when using task buffer (unless using USB CDC on ESP32) // The loop will be enabled automatically when messages arrive this->disable_loop_when_buffer_empty_(); diff --git a/esphome/components/logger/logger.h b/esphome/components/logger/logger.h index 90a0d73aee..018f7655cf 100644 --- a/esphome/components/logger/logger.h +++ b/esphome/components/logger/logger.h @@ -358,7 +358,7 @@ class Logger : public Component { #ifdef USE_LIBRETINY UARTSelection uart_{UART_SELECTION_DEFAULT}; #endif -#if defined(USE_ESP32) || defined(USE_HOST) || defined(USE_LIBRETINY) || USE_ZEPHYR +#if defined(USE_ESP32) || defined(USE_HOST) || defined(USE_LIBRETINY) || defined(USE_ZEPHYR) bool main_task_recursion_guard_{false}; #ifdef USE_LIBRETINY bool non_main_task_recursion_guard_{false}; // Shared guard for all non-main tasks on LibreTiny @@ -462,7 +462,7 @@ class Logger : public Component { #endif // Zephyr needs loop working to check when CDC port is open -#if defined(USE_ESP32) || defined(USE_LIBRETINY) && !(defined(USE_ZEPHYR) || defined(USE_LOGGER_USB_CDC)) +#if defined(USE_ESPHOME_TASK_LOG_BUFFER) && !(defined(USE_ZEPHYR) || defined(USE_LOGGER_USB_CDC)) // Disable loop when task buffer is empty (with USB CDC check on ESP32) inline void disable_loop_when_buffer_empty_() { // Thread safety note: This is safe even if another task calls enable_loop_soon_any_context()