From 935d496c70f51fbf579976a4d441e4b2b2b14521 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 4 Feb 2026 07:10:28 +0100 Subject: [PATCH] tweak --- esphome/components/logger/logger.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/esphome/components/logger/logger.h b/esphome/components/logger/logger.h index 38e28f7624..46ddf22719 100644 --- a/esphome/components/logger/logger.h +++ b/esphome/components/logger/logger.h @@ -193,20 +193,17 @@ struct LogBuffer { } void HOT format_body(const char *format, va_list args) { this->format_vsnprintf_(format, args); - this->write_color_reset_(); - this->null_terminate_(); + this->finalize_(); } #ifdef USE_STORE_LOG_STR_IN_FLASH void HOT format_body_P(PGM_P format, va_list args) { this->format_vsnprintf_P_(format, args); - this->write_color_reset_(); - this->null_terminate_(); + this->finalize_(); } #endif void write_body(const char *text, size_t text_length) { this->write_(text, text_length); - this->write_color_reset_(); - this->null_terminate_(); + this->finalize_(); } private: @@ -215,6 +212,10 @@ struct LogBuffer { char *current_() { return this->data + this->pos; } inline void put_char_(char c) { this->data[this->pos++] = c; } inline 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;