From 92ad6286aa0440292caac66eb9374474608bdd36 Mon Sep 17 00:00:00 2001 From: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com> Date: Thu, 13 Feb 2025 14:56:08 -0500 Subject: [PATCH] [logger] Fix bug causing global log level to be overwritten (#8248) --- esphome/components/logger/__init__.py | 4 ++-- esphome/components/logger/logger.cpp | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/esphome/components/logger/__init__.py b/esphome/components/logger/__init__.py index a89bf95c77..113f306327 100644 --- a/esphome/components/logger/__init__.py +++ b/esphome/components/logger/__init__.py @@ -247,8 +247,8 @@ async def to_code(config): ) cg.add(log.pre_setup()) - for tag, level in config[CONF_LOGS].items(): - cg.add(log.set_log_level(tag, LOG_LEVELS[level])) + for tag, log_level in config[CONF_LOGS].items(): + cg.add(log.set_log_level(tag, LOG_LEVELS[log_level])) cg.add_define("USE_LOGGER") this_severity = LOG_LEVEL_SEVERITY.index(level) diff --git a/esphome/components/logger/logger.cpp b/esphome/components/logger/logger.cpp index 79fc4cf499..57f0ba9f9a 100644 --- a/esphome/components/logger/logger.cpp +++ b/esphome/components/logger/logger.cpp @@ -102,9 +102,6 @@ void Logger::log_vprintf_(int level, const char *tag, int line, const __FlashStr #endif int HOT Logger::level_for(const char *tag) { - // Uses std::vector<> for low memory footprint, though the vector - // could be sorted to minimize lookup times. This feature isn't used that - // much anyway so it doesn't matter too much. if (this->log_levels_.count(tag) != 0) return this->log_levels_[tag]; return this->current_level_;