1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-07 12:23:47 +01:00

handle >999

This commit is contained in:
J. Nick Koston
2025-10-03 00:30:43 +02:00
parent aa1c5b5daa
commit ed907f842d

View File

@@ -355,18 +355,19 @@ class Logger : public Component {
buffer[pos++] = '[';
copy_string(buffer, pos, tag);
buffer[pos++] = ':';
if (line > 999) {
buffer[pos++] = 'B';
buffer[pos++] = 'I';
buffer[pos++] = 'G';
} else {
// Format line number without modulo operations (passed by value, safe to mutate)
if [[unlikely]]
(line > 999) {
int thousands = line / 1000;
buffer[pos++] = '0' + thousands;
line -= thousands * 1000;
}
int hundreds = line / 100;
int remainder = line - hundreds * 100;
int tens = remainder / 10;
buffer[pos++] = '0' + hundreds;
buffer[pos++] = '0' + tens;
buffer[pos++] = '0' + (remainder - tens * 10);
}
buffer[pos++] = ']';
#if defined(USE_ESP32) || defined(USE_LIBRETINY) || defined(USE_ZEPHYR)