log: formatting: Add configuration for blue DBG log
It's usual to show debug logs as blue. Showing dbg and info with different colors are good, but it's preferable to keep info logs with default color. Signed-off-by: Félix Piédallu <felix@piedallu.me>
This commit is contained in:
parent
a390f450ec
commit
61e5958eff
4 changed files with 8 additions and 2 deletions
|
@ -145,6 +145,9 @@ if LOG_BACKEND_SHOW_COLOR
|
|||
config LOG_INFO_COLOR_GREEN
|
||||
bool "Use green color for info level logs"
|
||||
|
||||
config LOG_DBG_COLOR_BLUE
|
||||
bool "Use blue color for debug level logs"
|
||||
|
||||
endif # LOG_BACKEND_SHOW_COLOR
|
||||
|
||||
config LOG_TAG_MAX_LEN
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#define LOG_COLOR_CODE_RED "\x1B[1;31m"
|
||||
#define LOG_COLOR_CODE_GREEN "\x1B[1;32m"
|
||||
#define LOG_COLOR_CODE_YELLOW "\x1B[1;33m"
|
||||
#define LOG_COLOR_CODE_BLUE "\x1B[1;34m"
|
||||
|
||||
#define HEXDUMP_BYTES_IN_LINE 16
|
||||
|
||||
|
@ -41,7 +42,7 @@ static const char *const colors[] = {
|
|||
LOG_COLOR_CODE_RED, /* err */
|
||||
LOG_COLOR_CODE_YELLOW, /* warn */
|
||||
IS_ENABLED(CONFIG_LOG_INFO_COLOR_GREEN) ? LOG_COLOR_CODE_GREEN : NULL, /* info */
|
||||
NULL /* dbg */
|
||||
IS_ENABLED(CONFIG_LOG_DBG_COLOR_BLUE) ? LOG_COLOR_CODE_BLUE : NULL, /* dbg */
|
||||
};
|
||||
|
||||
static uint32_t freq;
|
||||
|
|
|
@ -4,3 +4,4 @@ CONFIG_LOG=y
|
|||
CONFIG_LOG_OUTPUT=y
|
||||
CONFIG_LOG_PRINTK=n
|
||||
CONFIG_ZTEST_STACK_SIZE=1152
|
||||
CONFIG_LOG_DBG_COLOR_BLUE=y
|
||||
|
|
|
@ -192,13 +192,14 @@ ZTEST(test_log_output, test_colors)
|
|||
#define LOG_COLOR_CODE_RED "\x1B[1;31m"
|
||||
#define LOG_COLOR_CODE_GREEN "\x1B[1;32m"
|
||||
#define LOG_COLOR_CODE_YELLOW "\x1B[1;33m"
|
||||
#define LOG_COLOR_CODE_BLUE "\x1B[1;34m"
|
||||
|
||||
char package[256];
|
||||
static const char *const exp_strs[] = {
|
||||
LOG_COLOR_CODE_RED "<err> " SNAME ": " TEST_STR LOG_COLOR_CODE_DEFAULT "\r\n",
|
||||
LOG_COLOR_CODE_YELLOW "<wrn> " SNAME ": " TEST_STR LOG_COLOR_CODE_DEFAULT "\r\n",
|
||||
LOG_COLOR_CODE_DEFAULT "<inf> " SNAME ": " TEST_STR LOG_COLOR_CODE_DEFAULT "\r\n",
|
||||
LOG_COLOR_CODE_DEFAULT "<dbg> " SNAME ": " TEST_STR LOG_COLOR_CODE_DEFAULT "\r\n"
|
||||
LOG_COLOR_CODE_BLUE "<dbg> " SNAME ": " TEST_STR LOG_COLOR_CODE_DEFAULT "\r\n"
|
||||
};
|
||||
uint8_t levels[] = {LOG_LEVEL_ERR, LOG_LEVEL_WRN, LOG_LEVEL_INF, LOG_LEVEL_DBG};
|
||||
uint32_t flags = LOG_OUTPUT_FLAG_LEVEL | LOG_OUTPUT_FLAG_COLORS;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue