[esp-idf-monitor] Print colors based on log level (W/, E/, etc) (IDFGH-12250)
nebkat opened this issue · 1 comments
Is your feature request related to a problem?
CONFIG_LOG_COLORS
works by embedding ANSI escape sequences in every ESP_LOG*
format string corresponding to the log level. While this is very useful as a quick way to produce nicer log outputs, it has a number of disadvantages:
- Binary size
- Every singe
ESP_LOG*
format string becomes 11 bytes longer due to the added escape codes
- Every singe
- Unsupported consoles
- When reading logs outside of consoles that support the escape sequences it produces mangled text
- Additional processing
- ANSI codes still sometimes require additional processing to filter out and replace with native colors
Describe the solution you'd like.
All ESP_LOG
messages are prefixed with the log level (V
/D
/I
/W
/E
) and easily recognizable due to being followed by brackets with timestamp / system time.
I (29) boot: ESP-IDF v5.2 2nd stage bootloader
I (29) boot: compile time Feb 15 2024 20:27:36
My proposal is to have esp-idf-monitor
have a flag to detect the log levels from this prefix and print the colors on the host. Log messages are already parsed for providing user hints so this could easily be added.
Aside from removing the disadvantages listed in the previous section, this would also significantly improve developer experience in projects where colors have to be disabled (or have historically been disabled on existing builds).
Describe alternatives you've considered.
No response
Additional context.
No response
Thank you for the suggestion!