Bluetooth: Convert monitor protocol to a logger backend

Convert the monitor protocol to a proper logger backend. This also
means that our log.h headerfile gets greatly simplified.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
Johan Hedberg 2018-10-18 19:32:41 +03:00 committed by Carles Cufí
commit 9f18ff9baf
3 changed files with 135 additions and 96 deletions

View file

@ -26,31 +26,6 @@ extern "C" {
#define BT_DBG_ENABLED 1
#endif
#if defined(CONFIG_BT_DEBUG_MONITOR)
#include <stdio.h>
/* These defines follow the values used by syslog(2) */
#define BT_LOG_ERR 3
#define BT_LOG_WARN 4
#define BT_LOG_INFO 6
#define BT_LOG_DBG 7
__printf_like(2, 3) void bt_log(int prio, const char *fmt, ...);
#define BT_DBG(fmt, ...) \
if (BT_DBG_ENABLED) { \
bt_log(BT_LOG_DBG, "%s (%p): " fmt, \
__func__, k_current_get(), ##__VA_ARGS__); \
}
#define BT_ERR(fmt, ...) bt_log(BT_LOG_ERR, "%s: " fmt, \
__func__, ##__VA_ARGS__)
#define BT_WARN(fmt, ...) bt_log(BT_LOG_WARN, "%s: " fmt, \
__func__, ##__VA_ARGS__)
#define BT_INFO(fmt, ...) bt_log(BT_LOG_INFO, fmt, ##__VA_ARGS__)
#elif defined(CONFIG_BT_DEBUG_LOG)
#if BT_DBG_ENABLED
#define LOG_LEVEL LOG_LEVEL_DBG
#else
@ -73,20 +48,6 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
#define BT_INFO(fmt, ...) LOG_INF(fmt, ##__VA_ARGS__)
#else
static inline __printf_like(1, 2) void _bt_log_dummy(const char *fmt, ...) {};
#define BT_DBG(fmt, ...) \
if (0) { \
_bt_log_dummy(fmt, ##__VA_ARGS__); \
}
#define BT_ERR BT_DBG
#define BT_WARN BT_DBG
#define BT_INFO BT_DBG
#endif
#define BT_ASSERT(cond) if (!(cond)) { \
BT_ERR("assert: '" #cond "' failed"); \
k_oops(); \