diff options
author | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2016-04-27 17:57:03 +0300 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2016-06-01 05:04:10 +0000 |
commit | f6dd1e414453cbd48edf5289b3ec952d2f5e6b45 (patch) | |
tree | b96a5755a2ba62884dded5d3582f6b03d737641d | |
parent | ab833c74c540ed0940f63e42c6fb617f1a0e8a4e (diff) |
Bluetooth: Add support for using SYS_LOG
This add CONFIG_BLUETOOTH_DEBUG_LOG which depends on SYS_LOG since the
later can actually use either CONFIG_PRINTK or CONFIG_STDOUT_CONSOLE.
Change-Id: Ib2974d1331f6c91d119a218ec95e8bf01069377b
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
-rw-r--r-- | include/bluetooth/log.h | 32 | ||||
-rw-r--r-- | net/bluetooth/Kconfig | 7 | ||||
-rw-r--r-- | samples/bluetooth/beacon/prj.conf | 2 | ||||
-rw-r--r-- | samples/bluetooth/beacon/prj_nble.conf | 2 | ||||
-rw-r--r-- | samples/bluetooth/central_hr/prj.conf | 2 | ||||
-rw-r--r-- | samples/bluetooth/ipsp/prj_nimble.conf | 2 | ||||
-rw-r--r-- | samples/bluetooth/peripheral/prj.conf | 2 | ||||
-rw-r--r-- | samples/bluetooth/peripheral/prj_nble.conf | 2 | ||||
-rw-r--r-- | samples/bluetooth/peripheral_esp/prj_nble.conf | 2 | ||||
-rw-r--r-- | samples/bluetooth/peripheral_hr/prj.conf | 2 | ||||
-rw-r--r-- | samples/bluetooth/peripheral_hr/prj_nble.conf | 2 | ||||
-rw-r--r-- | samples/net/echo_client/prj_bt.conf | 2 | ||||
-rw-r--r-- | samples/net/echo_server/prj_bt.conf | 2 | ||||
-rw-r--r-- | tests/bluetooth/init/prj.conf | 2 | ||||
-rw-r--r-- | tests/bluetooth/init/prj_17.conf | 2 | ||||
-rw-r--r-- | tests/bluetooth/init/prj_h5_dbg.conf | 2 | ||||
-rw-r--r-- | tests/bluetooth/shell/prj.conf | 2 | ||||
-rw-r--r-- | tests/bluetooth/shell/prj_nble.conf | 2 | ||||
-rw-r--r-- | tests/bluetooth/shell/prj_nimble.conf | 2 | ||||
-rw-r--r-- | tests/bluetooth/test_bluetooth/prj.conf | 2 | ||||
-rw-r--r-- | tests/bluetooth/tester/prj.conf | 2 |
21 files changed, 34 insertions, 43 deletions
diff --git a/include/bluetooth/log.h b/include/bluetooth/log.h index e78fa9560..e88c9c20d 100644 --- a/include/bluetooth/log.h +++ b/include/bluetooth/log.h @@ -20,13 +20,12 @@ #ifndef __BT_LOG_H #define __BT_LOG_H -#include <stdio.h> - #ifdef __cplusplus extern "C" { #endif #if defined(CONFIG_BLUETOOTH_DEBUG_MONITOR) +#include <stdio.h> /* These defines follow the values used by syslog(2) */ #define BT_LOG_ERR 3 @@ -49,27 +48,18 @@ void bt_log(int prio, const char *fmt, ...); /* Enabling debug increases stack size requirement considerably */ #define BT_STACK_DEBUG_EXTRA 512 -#elif defined(CONFIG_BLUETOOTH_DEBUG_STDOUT) +#elif defined(CONFIG_BLUETOOTH_DEBUG_LOG) #include <nanokernel.h> - -#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 - -#define BT_DBG(fmt, ...) printf("bt: %s (%p): " fmt "\n", __func__, \ - sys_thread_self_get(), ##__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 SYS_LOG_DOMAIN "bt" +#define SYS_LOG_LEVEL SYS_LOG_LEVEL_DEBUG +#include <misc/sys_log.h> + +#define BT_DBG(fmt, ...) SYS_LOG_DBG("(%p)" fmt, sys_thread_self_get(), \ + ##__VA_ARGS__) +#define BT_ERR(fmt, ...) SYS_LOG_ERR(fmt, ##__VA_ARGS__) +#define BT_WARN(fmt, ...) SYS_LOG_WRN(fmt, ##__VA_ARGS__) +#define BT_INFO(fmt, ...) SYS_LOG_INF(fmt, ##__VA_ARGS__) #define BT_ASSERT(cond) if (!(cond)) { \ BT_ERR("assert: '" #cond "' failed"); \ } diff --git a/net/bluetooth/Kconfig b/net/bluetooth/Kconfig index e5d82d13b..06601ffd3 100644 --- a/net/bluetooth/Kconfig +++ b/net/bluetooth/Kconfig @@ -268,10 +268,10 @@ config BLUETOOTH_DEBUG_NONE help Select this to disable all Bluetooth debug logs. -config BLUETOOTH_DEBUG_STDOUT +config BLUETOOTH_DEBUG_LOG bool "Normal printf-style to console" select BLUETOOTH_DEBUG - select STDOUT_CONSOLE + select SYS_LOG help This option enables Bluetooth debug going to standard serial console. @@ -297,7 +297,8 @@ endchoice config BLUETOOTH_DEBUG_COLOR bool "Use colored logs" - depends on BLUETOOTH_DEBUG_STDOUT + depends on BLUETOOTH_DEBUG_LOG + select SYS_LOG_SHOW_COLOR default y help Use color in the logs. This requires an ANSI capable terminal. diff --git a/samples/bluetooth/beacon/prj.conf b/samples/bluetooth/beacon/prj.conf index 6cf967b6d..289635c92 100644 --- a/samples/bluetooth/beacon/prj.conf +++ b/samples/bluetooth/beacon/prj.conf @@ -1,3 +1,3 @@ CONFIG_BLUETOOTH=y CONFIG_BLUETOOTH_LE=y -CONFIG_BLUETOOTH_DEBUG_STDOUT=y +CONFIG_BLUETOOTH_DEBUG_LOG=y diff --git a/samples/bluetooth/beacon/prj_nble.conf b/samples/bluetooth/beacon/prj_nble.conf index 774b770b0..97e882cc1 100644 --- a/samples/bluetooth/beacon/prj_nble.conf +++ b/samples/bluetooth/beacon/prj_nble.conf @@ -2,4 +2,4 @@ CONFIG_BLUETOOTH=y CONFIG_BLUETOOTH_STACK_NBLE=y CONFIG_NBLE=y CONFIG_ARC_INIT=n -CONFIG_BLUETOOTH_DEBUG_STDOUT=y +CONFIG_BLUETOOTH_DEBUG_LOG=y diff --git a/samples/bluetooth/central_hr/prj.conf b/samples/bluetooth/central_hr/prj.conf index 1e3e3d3da..d4aa8314f 100644 --- a/samples/bluetooth/central_hr/prj.conf +++ b/samples/bluetooth/central_hr/prj.conf @@ -1,6 +1,6 @@ CONFIG_BLUETOOTH=y CONFIG_BLUETOOTH_LE=y -CONFIG_BLUETOOTH_DEBUG_STDOUT=y +CONFIG_BLUETOOTH_DEBUG_LOG=y CONFIG_BLUETOOTH_CENTRAL=y CONFIG_BLUETOOTH_SMP=y CONFIG_BLUETOOTH_GATT_CLIENT=y diff --git a/samples/bluetooth/ipsp/prj_nimble.conf b/samples/bluetooth/ipsp/prj_nimble.conf index 3941673db..9ddae7806 100644 --- a/samples/bluetooth/ipsp/prj_nimble.conf +++ b/samples/bluetooth/ipsp/prj_nimble.conf @@ -4,4 +4,4 @@ CONFIG_NETWORKING_WITH_BT=y CONFIG_IP_BUF_RX_SIZE=5 CONFIG_IP_BUF_TX_SIZE=3 CONFIG_ARC_INIT=n -CONFIG_BLUETOOTH_DEBUG_STDOUT=y +CONFIG_BLUETOOTH_DEBUG_LOG=y diff --git a/samples/bluetooth/peripheral/prj.conf b/samples/bluetooth/peripheral/prj.conf index 6790f4926..b10623b79 100644 --- a/samples/bluetooth/peripheral/prj.conf +++ b/samples/bluetooth/peripheral/prj.conf @@ -1,6 +1,6 @@ CONFIG_BLUETOOTH=y CONFIG_BLUETOOTH_LE=y -CONFIG_BLUETOOTH_DEBUG_STDOUT=y +CONFIG_BLUETOOTH_DEBUG_LOG=y CONFIG_BLUETOOTH_SMP=y CONFIG_BLUETOOTH_SIGNING=y CONFIG_BLUETOOTH_PERIPHERAL=y diff --git a/samples/bluetooth/peripheral/prj_nble.conf b/samples/bluetooth/peripheral/prj_nble.conf index 774b770b0..97e882cc1 100644 --- a/samples/bluetooth/peripheral/prj_nble.conf +++ b/samples/bluetooth/peripheral/prj_nble.conf @@ -2,4 +2,4 @@ CONFIG_BLUETOOTH=y CONFIG_BLUETOOTH_STACK_NBLE=y CONFIG_NBLE=y CONFIG_ARC_INIT=n -CONFIG_BLUETOOTH_DEBUG_STDOUT=y +CONFIG_BLUETOOTH_DEBUG_LOG=y diff --git a/samples/bluetooth/peripheral_esp/prj_nble.conf b/samples/bluetooth/peripheral_esp/prj_nble.conf index 774b770b0..97e882cc1 100644 --- a/samples/bluetooth/peripheral_esp/prj_nble.conf +++ b/samples/bluetooth/peripheral_esp/prj_nble.conf @@ -2,4 +2,4 @@ CONFIG_BLUETOOTH=y CONFIG_BLUETOOTH_STACK_NBLE=y CONFIG_NBLE=y CONFIG_ARC_INIT=n -CONFIG_BLUETOOTH_DEBUG_STDOUT=y +CONFIG_BLUETOOTH_DEBUG_LOG=y diff --git a/samples/bluetooth/peripheral_hr/prj.conf b/samples/bluetooth/peripheral_hr/prj.conf index 3bd942ffe..a9de3174c 100644 --- a/samples/bluetooth/peripheral_hr/prj.conf +++ b/samples/bluetooth/peripheral_hr/prj.conf @@ -1,6 +1,6 @@ CONFIG_BLUETOOTH=y CONFIG_BLUETOOTH_LE=y -CONFIG_BLUETOOTH_DEBUG_STDOUT=y +CONFIG_BLUETOOTH_DEBUG_LOG=y CONFIG_BLUETOOTH_SMP=y CONFIG_BLUETOOTH_PERIPHERAL=y CONFIG_BLUETOOTH_GATT_DYNAMIC_DB=y diff --git a/samples/bluetooth/peripheral_hr/prj_nble.conf b/samples/bluetooth/peripheral_hr/prj_nble.conf index 774b770b0..97e882cc1 100644 --- a/samples/bluetooth/peripheral_hr/prj_nble.conf +++ b/samples/bluetooth/peripheral_hr/prj_nble.conf @@ -2,4 +2,4 @@ CONFIG_BLUETOOTH=y CONFIG_BLUETOOTH_STACK_NBLE=y CONFIG_NBLE=y CONFIG_ARC_INIT=n -CONFIG_BLUETOOTH_DEBUG_STDOUT=y +CONFIG_BLUETOOTH_DEBUG_LOG=y diff --git a/samples/net/echo_client/prj_bt.conf b/samples/net/echo_client/prj_bt.conf index 39bb5d72f..25f5b0137 100644 --- a/samples/net/echo_client/prj_bt.conf +++ b/samples/net/echo_client/prj_bt.conf @@ -1,7 +1,7 @@ CONFIG_TEST_RANDOM_GENERATOR=y CONFIG_BLUETOOTH=y CONFIG_BLUETOOTH_LE=y -CONFIG_BLUETOOTH_DEBUG_STDOUT=y +CONFIG_BLUETOOTH_DEBUG_LOG=y CONFIG_BLUETOOTH_SMP=y CONFIG_BLUETOOTH_SIGNING=y CONFIG_BLUETOOTH_PERIPHERAL=y diff --git a/samples/net/echo_server/prj_bt.conf b/samples/net/echo_server/prj_bt.conf index d39267b6c..253d93aef 100644 --- a/samples/net/echo_server/prj_bt.conf +++ b/samples/net/echo_server/prj_bt.conf @@ -1,6 +1,6 @@ CONFIG_BLUETOOTH=y CONFIG_BLUETOOTH_LE=y -CONFIG_BLUETOOTH_DEBUG_STDOUT=y +CONFIG_BLUETOOTH_DEBUG_LOG=y CONFIG_BLUETOOTH_DEBUG_L2CAP=y CONFIG_BLUETOOTH_SMP=y CONFIG_BLUETOOTH_SIGNING=y diff --git a/tests/bluetooth/init/prj.conf b/tests/bluetooth/init/prj.conf index 6cf967b6d..289635c92 100644 --- a/tests/bluetooth/init/prj.conf +++ b/tests/bluetooth/init/prj.conf @@ -1,3 +1,3 @@ CONFIG_BLUETOOTH=y CONFIG_BLUETOOTH_LE=y -CONFIG_BLUETOOTH_DEBUG_STDOUT=y +CONFIG_BLUETOOTH_DEBUG_LOG=y diff --git a/tests/bluetooth/init/prj_17.conf b/tests/bluetooth/init/prj_17.conf index ae5c4015e..6ff1170af 100644 --- a/tests/bluetooth/init/prj_17.conf +++ b/tests/bluetooth/init/prj_17.conf @@ -10,7 +10,7 @@ CONFIG_BLUETOOTH_USE_DEBUG_KEYS=y CONFIG_BLUETOOTH_L2CAP_DYNAMIC_CHANNEL=y CONFIG_BLUETOOTH_GATT_DYNAMIC_DB=y CONFIG_BLUETOOTH_GATT_CLIENT=y -CONFIG_BLUETOOTH_DEBUG_STDOUT=y +CONFIG_BLUETOOTH_DEBUG_LOG=y CONFIG_BLUETOOTH_DEBUG_HCI_CORE=y CONFIG_BLUETOOTH_DEBUG_CONN=y CONFIG_BLUETOOTH_DEBUG_KEYS=y diff --git a/tests/bluetooth/init/prj_h5_dbg.conf b/tests/bluetooth/init/prj_h5_dbg.conf index caea16d2b..555be0c1f 100644 --- a/tests/bluetooth/init/prj_h5_dbg.conf +++ b/tests/bluetooth/init/prj_h5_dbg.conf @@ -1,5 +1,5 @@ CONFIG_BLUETOOTH=y CONFIG_BLUETOOTH_H5=y CONFIG_BLUETOOTH_LE=y -CONFIG_BLUETOOTH_DEBUG_STDOUT=y +CONFIG_BLUETOOTH_DEBUG_LOG=y CONFIG_BLUETOOTH_DEBUG_DRIVER=y diff --git a/tests/bluetooth/shell/prj.conf b/tests/bluetooth/shell/prj.conf index f3ce40b58..f53b8862f 100644 --- a/tests/bluetooth/shell/prj.conf +++ b/tests/bluetooth/shell/prj.conf @@ -3,7 +3,7 @@ CONFIG_BLUETOOTH=y CONFIG_BLUETOOTH_LE=y CONFIG_BLUETOOTH_BREDR=y CONFIG_CONSOLE_HANDLER=y -CONFIG_BLUETOOTH_DEBUG_STDOUT=y +CONFIG_BLUETOOTH_DEBUG_LOG=y CONFIG_BLUETOOTH_CENTRAL=y CONFIG_BLUETOOTH_PERIPHERAL=y CONFIG_BLUETOOTH_PRIVACY=y diff --git a/tests/bluetooth/shell/prj_nble.conf b/tests/bluetooth/shell/prj_nble.conf index 642036669..44fbc998a 100644 --- a/tests/bluetooth/shell/prj_nble.conf +++ b/tests/bluetooth/shell/prj_nble.conf @@ -6,4 +6,4 @@ CONFIG_NBLE=y CONFIG_ARC_INIT=n CONFIG_CONSOLE_HANDLER=y CONFIG_CONSOLE_HANDLER_SHELL=y -CONFIG_BLUETOOTH_DEBUG_STDOUT=y +CONFIG_BLUETOOTH_DEBUG_LOG=y diff --git a/tests/bluetooth/shell/prj_nimble.conf b/tests/bluetooth/shell/prj_nimble.conf index faec958ad..36f32af7b 100644 --- a/tests/bluetooth/shell/prj_nimble.conf +++ b/tests/bluetooth/shell/prj_nimble.conf @@ -2,7 +2,7 @@ CONFIG_MINIMAL_LIBC_EXTENDED=y CONFIG_BLUETOOTH=y CONFIG_BLUETOOTH_LE=y CONFIG_CONSOLE_HANDLER=y -CONFIG_BLUETOOTH_DEBUG_STDOUT=y +CONFIG_BLUETOOTH_DEBUG_LOG=y CONFIG_BLUETOOTH_CENTRAL=y CONFIG_BLUETOOTH_PERIPHERAL=y CONFIG_BLUETOOTH_PRIVACY=y diff --git a/tests/bluetooth/test_bluetooth/prj.conf b/tests/bluetooth/test_bluetooth/prj.conf index afd3716e8..265515d82 100644 --- a/tests/bluetooth/test_bluetooth/prj.conf +++ b/tests/bluetooth/test_bluetooth/prj.conf @@ -4,5 +4,5 @@ CONFIG_TEST_RANDOM_GENERATOR=y CONFIG_BLUETOOTH=y CONFIG_BLUETOOTH_LE=y CONFIG_BLUETOOTH_NO_DRIVER=y -CONFIG_BLUETOOTH_DEBUG_STDOUT=y +CONFIG_BLUETOOTH_DEBUG_LOG=y CONFIG_UART_INTERRUPT_DRIVEN=n diff --git a/tests/bluetooth/tester/prj.conf b/tests/bluetooth/tester/prj.conf index bf32cd7ab..9a22ec3ab 100644 --- a/tests/bluetooth/tester/prj.conf +++ b/tests/bluetooth/tester/prj.conf @@ -8,7 +8,7 @@ CONFIG_BLUETOOTH_SMP=y CONFIG_BLUETOOTH_SIGNING=y CONFIG_BLUETOOTH_GATT_DYNAMIC_DB=y CONFIG_BLUETOOTH_GATT_CLIENT=y -CONFIG_BLUETOOTH_DEBUG_STDOUT=y +CONFIG_BLUETOOTH_DEBUG_LOG=y CONFIG_BLUETOOTH_DEBUG_HCI_CORE=y CONFIG_BLUETOOTH_DEBUG_BUF=y CONFIG_BLUETOOTH_DEBUG_CONN=y |