mirror of
https://github.com/esphome/esphome.git
synced 2025-08-05 09:57:47 +00:00
Merge remote-tracking branch 'origin/integration' into integration
This commit is contained in:
commit
a80d3012bd
@ -90,6 +90,25 @@ void HOT Logger::log_vprintf_(uint8_t level, const char *tag, int line, const ch
|
|||||||
#ifdef USE_STORE_LOG_STR_IN_FLASH
|
#ifdef USE_STORE_LOG_STR_IN_FLASH
|
||||||
// Implementation for ESP8266 with flash string support.
|
// Implementation for ESP8266 with flash string support.
|
||||||
// Note: USE_STORE_LOG_STR_IN_FLASH is only defined for ESP8266.
|
// Note: USE_STORE_LOG_STR_IN_FLASH is only defined for ESP8266.
|
||||||
|
//
|
||||||
|
// This function handles format strings stored in flash memory (PROGMEM) to save RAM.
|
||||||
|
// The buffer is used in a special way to avoid allocating extra memory:
|
||||||
|
//
|
||||||
|
// Memory layout during execution:
|
||||||
|
// Step 1: Copy format string from flash to buffer
|
||||||
|
// tx_buffer_: [format_string][null][.....................]
|
||||||
|
// tx_buffer_at_: ------------------^
|
||||||
|
// msg_start: saved here -----------^
|
||||||
|
//
|
||||||
|
// Step 2: format_log_to_buffer_with_terminator_ reads format string from beginning
|
||||||
|
// and writes formatted output starting at msg_start position
|
||||||
|
// tx_buffer_: [format_string][null][formatted_message][null]
|
||||||
|
// tx_buffer_at_: -------------------------------------^
|
||||||
|
//
|
||||||
|
// Step 3: Output the formatted message (starting at msg_start)
|
||||||
|
// write_msg_ and callbacks receive: this->tx_buffer_ + msg_start
|
||||||
|
// which points to: [formatted_message][null]
|
||||||
|
//
|
||||||
void Logger::log_vprintf_(uint8_t level, const char *tag, int line, const __FlashStringHelper *format,
|
void Logger::log_vprintf_(uint8_t level, const char *tag, int line, const __FlashStringHelper *format,
|
||||||
va_list args) { // NOLINT
|
va_list args) { // NOLINT
|
||||||
if (level > this->level_for(tag) || global_recursion_guard_)
|
if (level > this->level_for(tag) || global_recursion_guard_)
|
||||||
@ -121,7 +140,8 @@ void Logger::log_vprintf_(uint8_t level, const char *tag, int line, const __Flas
|
|||||||
if (this->baud_rate_ > 0) {
|
if (this->baud_rate_ > 0) {
|
||||||
this->write_msg_(this->tx_buffer_ + msg_start);
|
this->write_msg_(this->tx_buffer_ + msg_start);
|
||||||
}
|
}
|
||||||
size_t msg_length = this->tx_buffer_at_ - msg_start - 1; // -1 to exclude null terminator
|
size_t msg_length =
|
||||||
|
this->tx_buffer_at_ - msg_start; // Don't subtract 1 - tx_buffer_at_ is already at the null terminator position
|
||||||
this->log_callback_.call(level, tag, this->tx_buffer_ + msg_start, msg_length);
|
this->log_callback_.call(level, tag, this->tx_buffer_ + msg_start, msg_length);
|
||||||
|
|
||||||
global_recursion_guard_ = false;
|
global_recursion_guard_ = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user