From 2de3b6aed7045059052e72b6a0798d8cf29f9a0c Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 4 Feb 2026 07:24:44 +0100 Subject: [PATCH] tweak --- esphome/components/logger/logger.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/esphome/components/logger/logger.h b/esphome/components/logger/logger.h index ed815f1dacd..12799c16f3e 100644 --- a/esphome/components/logger/logger.h +++ b/esphome/components/logger/logger.h @@ -222,11 +222,6 @@ struct LogBuffer { bool full_() const { return this->pos >= this->size; } uint16_t remaining_() const { return this->size - this->pos; } char *current_() { return this->data + this->pos; } - void null_terminate_() { this->data[this->full_() ? this->size - 1 : this->pos] = '\0'; } - void finalize_() { - this->write_color_reset_(); - this->null_terminate_(); - } void write_(const char *value, size_t length) { if (this->full_()) return; @@ -237,9 +232,12 @@ struct LogBuffer { this->pos += copy_len; } } - void write_color_reset_() { + void finalize_() { + // Write color reset sequence static constexpr uint16_t RESET_COLOR_LEN = sizeof(ESPHOME_LOG_RESET_COLOR) - 1; this->write_(ESPHOME_LOG_RESET_COLOR, RESET_COLOR_LEN); + // Null terminate + this->data[this->full_() ? this->size - 1 : this->pos] = '\0'; } void strip_trailing_newlines_() { while (this->pos > 0 && this->data[this->pos - 1] == '\n')