diff --git a/include/bluetooth/log.h b/include/bluetooth/log.h index 1c96529eb67..33ecf378fb0 100644 --- a/include/bluetooth/log.h +++ b/include/bluetooth/log.h @@ -22,11 +22,23 @@ #include +#if defined(CONFIG_BLUETOOTH_DEBUG_COLOR) +#define BT_COLOR_OFF "\x1B[0m" +#define BT_COLOR_RED "\x1B[0;31m" +#define BT_COLOR_YELLOW "\x1B[0;33m" +#else +#define BT_COLOR_OFF "" +#define BT_COLOR_RED "" +#define BT_COLOR_YELLOW "" +#endif + #if defined(CONFIG_BLUETOOTH_DEBUG) #define BT_DBG(fmt, ...) printf("bt: %s (%p): " fmt "\n", __func__, \ sys_thread_self_get(), ##__VA_ARGS__) -#define BT_ERR(fmt, ...) printf("bt: %s: " fmt "\n", __func__, ##__VA_ARGS__) -#define BT_WARN(fmt, ...) printf("bt: %s: " fmt "\n", __func__, ##__VA_ARGS__) +#define BT_ERR(fmt, ...) printf("bt: %s: %s" fmt "%s\n", __func__, \ + BT_COLOR_RED, ##__VA_ARGS__, BT_COLOR_OFF) +#define BT_WARN(fmt, ...) printf("bt: %s: %s" fmt "%s\n", __func__, \ + BT_COLOR_YELLOW, ##__VA_ARGS__, BT_COLOR_OFF) #define BT_INFO(fmt, ...) printf("bt: " fmt "\n", ##__VA_ARGS__) #define BT_ASSERT(cond) if (!(cond)) { \ BT_ERR("bt: assert: '" #cond "' failed"); \ diff --git a/net/bluetooth/Kconfig b/net/bluetooth/Kconfig index d5ef8100200..42de1a6e361 100644 --- a/net/bluetooth/Kconfig +++ b/net/bluetooth/Kconfig @@ -172,6 +172,12 @@ config BLUETOOTH_DEBUG serial console. if BLUETOOTH_DEBUG +config BLUETOOTH_DEBUG_COLOR + bool "Use colored logs" + default y + help + Use color in the logs. This requires an ANSI capable terminal. + config BLUETOOTH_DEBUG_HCI_CORE bool "Bluetooth HCI core debug" default n