mirror of
https://github.com/esphome/esphome.git
synced 2025-10-03 10:32:21 +01:00
Merge branch 'logging_speed_up' into integration
This commit is contained in:
@@ -48,8 +48,17 @@ static const char *const LOG_LEVEL_COLORS[] = {
|
||||
ESPHOME_LOG_COLOR(ESPHOME_LOG_COLOR_WHITE), // VERY_VERBOSE
|
||||
};
|
||||
|
||||
static constexpr char LOG_LEVEL_LETTER_CHARS[] = {'\0', 'E', 'W', 'I', 'C', 'D', 'V'};
|
||||
static constexpr char LOG_LEVEL_LETTER_CHARS[] = {
|
||||
'\0', // NONE
|
||||
'E', // ERROR
|
||||
'W', // WARNING
|
||||
'I', // INFO
|
||||
'C', // CONFIG
|
||||
'D', // DEBUG
|
||||
'V', // VERBOSE (VERY_VERBOSE uses two 'V's)
|
||||
};
|
||||
static constexpr uint8_t ANSI_COLOR_LEN = 7;
|
||||
// Maximum header size: 35 bytes fixed + 32 bytes tag + 16 bytes thread name = 83 bytes (45 byte safety margin)
|
||||
static constexpr uint16_t MAX_HEADER_SIZE = 128;
|
||||
|
||||
#if defined(USE_ESP32) || defined(USE_ESP8266) || defined(USE_RP2040) || defined(USE_LIBRETINY) || defined(USE_ZEPHYR)
|
||||
@@ -315,6 +324,7 @@ class Logger : public Component {
|
||||
inline void HOT write_header_to_buffer_(uint8_t level, const char *tag, int line, const char *thread_name,
|
||||
char *buffer, uint16_t *buffer_at, uint16_t buffer_size) {
|
||||
uint16_t pos = *buffer_at;
|
||||
// Early return if insufficient space - intentionally don't update buffer_at to prevent partial writes
|
||||
if (pos + MAX_HEADER_SIZE > buffer_size)
|
||||
return;
|
||||
|
||||
|
Reference in New Issue
Block a user