1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-12 00:02:21 +01:00

Merge branch 'more_str_len_logger' into integration

This commit is contained in:
J. Nick Koston
2025-07-07 10:10:17 -05:00
2 changed files with 4 additions and 2 deletions

View File

@@ -355,7 +355,7 @@ class Logger : public Component {
}
inline void HOT write_footer_to_buffer_(char *buffer, uint16_t *buffer_at, uint16_t buffer_size) {
static const uint16_t RESET_COLOR_LEN = strlen(ESPHOME_LOG_RESET_COLOR);
static constexpr uint16_t RESET_COLOR_LEN = sizeof(ESPHOME_LOG_RESET_COLOR) - 1;
this->write_body_to_buffer_(ESPHOME_LOG_RESET_COLOR, RESET_COLOR_LEN, buffer, buffer_at, buffer_size);
}

View File

@@ -184,7 +184,9 @@ void HOT Logger::write_msg_(const char *msg) {
) {
puts(msg);
} else {
uart_write_bytes(this->uart_num_, msg, strlen(msg));
// Use tx_buffer_at_ if msg points to tx_buffer_, otherwise fall back to strlen
size_t len = (msg == this->tx_buffer_) ? this->tx_buffer_at_ : strlen(msg);
uart_write_bytes(this->uart_num_, msg, len);
uart_write_bytes(this->uart_num_, "\n", 1);
}
}