1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-07 20:33: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++] = '['; buffer[pos++] = '[';
copy_string(buffer, pos, tag); copy_string(buffer, pos, tag);
buffer[pos++] = ':'; buffer[pos++] = ':';
if (line > 999) { // Format line number without modulo operations (passed by value, safe to mutate)
buffer[pos++] = 'B'; if [[unlikely]]
buffer[pos++] = 'I'; (line > 999) {
buffer[pos++] = 'G'; int thousands = line / 1000;
} else { buffer[pos++] = '0' + thousands;
int hundreds = line / 100; line -= thousands * 1000;
int remainder = line - hundreds * 100; }
int tens = remainder / 10; int hundreds = line / 100;
buffer[pos++] = '0' + hundreds; int remainder = line - hundreds * 100;
buffer[pos++] = '0' + tens; int tens = remainder / 10;
buffer[pos++] = '0' + (remainder - tens * 10); buffer[pos++] = '0' + hundreds;
} buffer[pos++] = '0' + tens;
buffer[pos++] = '0' + (remainder - tens * 10);
buffer[pos++] = ']'; buffer[pos++] = ']';
#if defined(USE_ESP32) || defined(USE_LIBRETINY) || defined(USE_ZEPHYR) #if defined(USE_ESP32) || defined(USE_LIBRETINY) || defined(USE_ZEPHYR)