Skip to content

Commit f4a5c7d

Browse files
marinjurjeviccfriedt
authored andcommitted
logging: use green color for info log level
Info log messages don't have dedicated color which makes them harder to separate from debug logs. Introduce green color in log output for info level so it stands out like error and warning messages do. Signed-off-by: Marin Jurjević <[email protected]>
1 parent 1031cfd commit f4a5c7d

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

subsys/logging/Kconfig.formatting

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ config LOG_BACKEND_SHOW_COLOR
5858
help
5959
When enabled selected backend prints errors in red and warning in yellow.
6060

61+
if LOG_BACKEND_SHOW_COLOR
62+
63+
config LOG_INFO_COLOR_GREEN
64+
bool "Use green color for info level logs"
65+
66+
endif
67+
6168
config LOG_BACKEND_FORMAT_TIMESTAMP
6269
bool "Enable timestamp formatting in the backend"
6370
depends on LOG_BACKEND_UART || LOG_BACKEND_NATIVE_POSIX || LOG_BACKEND_RTT \

subsys/logging/log_output.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#define LOG_COLOR_CODE_DEFAULT "\x1B[0m"
1818
#define LOG_COLOR_CODE_RED "\x1B[1;31m"
19+
#define LOG_COLOR_CODE_GREEN "\x1B[1;32m"
1920
#define LOG_COLOR_CODE_YELLOW "\x1B[1;33m"
2021

2122
#define HEXDUMP_BYTES_IN_LINE 16
@@ -38,7 +39,7 @@ static const char *const colors[] = {
3839
NULL,
3940
LOG_COLOR_CODE_RED, /* err */
4041
LOG_COLOR_CODE_YELLOW, /* warn */
41-
NULL, /* info */
42+
IS_ENABLED(CONFIG_LOG_INFO_COLOR_GREEN) ? LOG_COLOR_CODE_GREEN : NULL, /* info */
4243
NULL /* dbg */
4344
};
4445

0 commit comments

Comments
 (0)