This commit defines a default log level at bluetooth subsystem level when module log level is not defined. Prior to this change, the bluetooth subsystem would use the firmware default log level. Signed-off-by: Olivier Martin <olivier.martin@proglove.de>
69 lines
1.6 KiB
C
69 lines
1.6 KiB
C
/** @file
|
|
* @brief Bluetooth subsystem logging helpers.
|
|
*/
|
|
|
|
/*
|
|
* Copyright (c) 2017 Nordic Semiconductor ASA
|
|
* Copyright (c) 2015-2016 Intel Corporation
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
#ifndef __BT_LOG_H
|
|
#define __BT_LOG_H
|
|
|
|
#include <linker/sections.h>
|
|
#include <offsets.h>
|
|
#include <zephyr.h>
|
|
|
|
#include <bluetooth/bluetooth.h>
|
|
#include <bluetooth/hci.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#if !defined(BT_DBG_ENABLED)
|
|
#define BT_DBG_ENABLED 1
|
|
#endif
|
|
|
|
#if BT_DBG_ENABLED
|
|
#define LOG_LEVEL LOG_LEVEL_DBG
|
|
#else
|
|
#define LOG_LEVEL CONFIG_BT_LOG_LEVEL
|
|
#endif
|
|
|
|
#include <logging/log.h>
|
|
|
|
LOG_MODULE_REGISTER(LOG_MODULE_NAME);
|
|
|
|
#if IS_ENABLED(CONFIG_LOG_FUNCTION_NAME)
|
|
#define BT_DBG(fmt, ...) LOG_DBG(fmt, ##__VA_ARGS__)
|
|
#define BT_ERR(fmt, ...) LOG_ERR(fmt, ##__VA_ARGS__)
|
|
#define BT_WARN(fmt, ...) LOG_WRN(fmt, ##__VA_ARGS__)
|
|
#else
|
|
#define BT_DBG(fmt, ...) LOG_DBG("%s: " fmt, __func__, ##__VA_ARGS__)
|
|
#define BT_ERR(fmt, ...) LOG_ERR("%s: " fmt, __func__, ##__VA_ARGS__)
|
|
#define BT_WARN(fmt, ...) LOG_WRN("%s: " fmt, __func__, ##__VA_ARGS__)
|
|
#endif
|
|
|
|
#define BT_INFO(fmt, ...) LOG_INF(fmt, ##__VA_ARGS__)
|
|
|
|
#define BT_ASSERT(cond) if (!(cond)) { \
|
|
BT_ERR("assert: '" #cond "' failed"); \
|
|
k_oops(); \
|
|
}
|
|
|
|
const char *bt_hex_real(const void *buf, size_t len);
|
|
const char *bt_addr_str_real(const bt_addr_t *addr);
|
|
const char *bt_addr_le_str_real(const bt_addr_le_t *addr);
|
|
|
|
#define bt_hex(buf, len) log_strdup(bt_hex_real(buf, len))
|
|
#define bt_addr_str(addr) log_strdup(bt_addr_str_real(addr))
|
|
#define bt_addr_le_str(addr) log_strdup(bt_addr_le_str_real(addr))
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* __BT_LOG_H */
|
|
|