diff --git a/esphome/components/logger/logger.cpp b/esphome/components/logger/logger.cpp index 3836d3134b..05ac6d2d87 100644 --- a/esphome/components/logger/logger.cpp +++ b/esphome/components/logger/logger.cpp @@ -39,8 +39,7 @@ void Logger::write_header_(int level, const char *tag, int line) { const char *color = LOG_LEVEL_COLORS[level]; const char *letter = LOG_LEVEL_LETTERS[level]; -#ifndef USE_ESP8266 -#if defined(USE_ARDUINO) || defined(USE_ESP_IDF) +#if defined(USE_ESP32) || defined(USE_LIBRETINY) void * current_task = xTaskGetCurrentTaskHandle(); #elif defined(USE_ZEPHYR) k_tid_t current_task = k_current_get(); @@ -48,19 +47,18 @@ void Logger::write_header_(int level, const char *tag, int line) { void * current_task = nullptr; #endif if (current_task == main_task_) { -#endif this->printf_to_buffer_("%s[%s][%s:%03u]: ", color, letter, tag, line); -#ifndef USE_ESP8266 } else { -#if defined(USE_ARDUINO) || defined(USE_ESP_IDF) +#if defined(USE_ESP32) || defined(USE_LIBRETINY) const char *thread_name = pcTaskGetName(current_task); #elif defined(USE_ZEPHYR) const char *thread_name = k_thread_name_get(current_task); +#else + const char *thread_name = ""; #endif this->printf_to_buffer_("%s[%s][%s:%03u]%s[%s]%s: ", color, letter, tag, line, ESPHOME_LOG_BOLD(ESPHOME_LOG_COLOR_RED), thread_name, color); } -#endif } void HOT Logger::log_vprintf_(int level, const char *tag, int line, const char *format, va_list args) { // NOLINT @@ -148,13 +146,11 @@ void HOT Logger::log_message_(int level, const char *tag, int offset) { Logger::Logger(uint32_t baud_rate, size_t tx_buffer_size) : baud_rate_(baud_rate), tx_buffer_size_(tx_buffer_size) { // add 1 to buffer size for null terminator this->tx_buffer_ = new char[this->tx_buffer_size_ + 1]; // NOLINT -#ifndef USE_ESP8266 -#if defined(USE_ARDUINO) || defined(USE_ESP_IDF) +#if defined(USE_ESP32) || defined(USE_LIBRETINY) this->main_task_ = xTaskGetCurrentTaskHandle(); #elif defined(USE_ZEPHYR) this->main_task_ = k_current_get(); #endif -#endif } #ifdef USE_LOGGER_USB_CDC