From 76c93b882d4bc8079b64fe5e49c5feb5f73484ff Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 26 Mar 2026 08:30:00 -1000 Subject: [PATCH] [logger] Use only compiled log level for verbose warning The compiled ESPHOME_LOG_LEVEL is what matters - all log calls up to that level are in the binary and will format/block UART regardless of runtime initial_level. --- esphome/components/logger/logger.cpp | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/esphome/components/logger/logger.cpp b/esphome/components/logger/logger.cpp index f6159277b0..237a4804aa 100644 --- a/esphome/components/logger/logger.cpp +++ b/esphome/components/logger/logger.cpp @@ -245,23 +245,15 @@ void Logger::dump_config() { dump_crash_(); #endif // Warn users that VERBOSE/VERY_VERBOSE logging impacts performance. - // The compiled log level (ESPHOME_LOG_LEVEL) is what matters here — even if - // initial_level is set lower at runtime, log messages at the compiled level - // are still formatted (vsnprintf) and written to UART which is blocking. + // Only the compiled log level matters — all log calls up to this level + // are in the binary and will be formatted (vsnprintf) and block UART. #if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERY_VERBOSE - if (this->current_level_ >= ESPHOME_LOG_LEVEL_VERY_VERBOSE) { - ESP_LOGW(TAG, "VERY_VERBOSE logging is active. This will significantly impact device performance and may cause " - "connection instability. This level is intended for short-term debugging only. " - "Set the log level to DEBUG or lower for long-term use."); - } else if (this->current_level_ >= ESPHOME_LOG_LEVEL_VERBOSE) { - ESP_LOGI(TAG, "VERBOSE logging is active. This will impact device performance and is intended for short-term " - "debugging only. Set the log level to DEBUG or lower for long-term use."); - } + ESP_LOGW(TAG, "VERY_VERBOSE logging is active. This will significantly impact device performance and may cause " + "connection instability. This level is intended for short-term debugging only. " + "Set the log level to DEBUG or lower for long-term use."); #elif ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERBOSE - if (this->current_level_ >= ESPHOME_LOG_LEVEL_VERBOSE) { - ESP_LOGI(TAG, "VERBOSE logging is active. This will impact device performance and is intended for short-term " - "debugging only. Set the log level to DEBUG or lower for long-term use."); - } + ESP_LOGI(TAG, "VERBOSE logging is active. This will impact device performance and is intended for short-term " + "debugging only. Set the log level to DEBUG or lower for long-term use."); #endif }