From 159e2bed69a9f32815128780f9ae6c20b6233875 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 4 Feb 2026 06:15:10 +0100 Subject: [PATCH] tweak --- esphome/components/logger/logger.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/esphome/components/logger/logger.h b/esphome/components/logger/logger.h index 407ad7c2c4..2f43e5625a 100644 --- a/esphome/components/logger/logger.h +++ b/esphome/components/logger/logger.h @@ -137,16 +137,6 @@ struct LogBuffer { LogBuffer(char *buf, uint16_t &buf_pos, uint16_t buf_size) : data(buf), pos(buf_pos), size(buf_size) { this->pos = 0; } - void write(const char *value, size_t length) { - if (this->full_()) - return; - const uint16_t available = this->remaining_(); - const size_t copy_len = (length < static_cast(available)) ? length : available; - if (copy_len > 0) { - memcpy(this->current_(), value, copy_len); - this->pos += copy_len; - } - } void add_newline() { if (this->pos < this->size) { this->data[this->pos++] = '\n'; @@ -204,7 +194,7 @@ struct LogBuffer { this->null_terminate_(); } void write_body(const char *text, size_t text_length) { - this->write(text, text_length); + this->write_(text, text_length); this->write_color_reset_(); this->null_terminate_(); } @@ -223,9 +213,19 @@ struct LogBuffer { char *current_() { return this->data + this->pos; } void put_char_(char c) { this->data[this->pos++] = c; } void null_terminate_() { this->data[this->full_() ? this->size - 1 : this->pos] = '\0'; } + void write_(const char *value, size_t length) { + if (this->full_()) + return; + const uint16_t available = this->remaining_(); + const size_t copy_len = (length < static_cast(available)) ? length : available; + if (copy_len > 0) { + memcpy(this->current_(), value, copy_len); + this->pos += copy_len; + } + } void write_color_reset_() { static constexpr uint16_t RESET_COLOR_LEN = sizeof(ESPHOME_LOG_RESET_COLOR) - 1; - this->write(ESPHOME_LOG_RESET_COLOR, RESET_COLOR_LEN); + this->write_(ESPHOME_LOG_RESET_COLOR, RESET_COLOR_LEN); } void strip_trailing_newlines_() { while (this->pos > 0 && this->data[this->pos - 1] == '\n')