2015-07-02 04:47:13 +08:00
|
|
|
/** @file
|
2015-06-16 22:25:37 +08:00
|
|
|
* @brief Bluetooth subsystem logging helpers.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2015 Intel Corporation
|
|
|
|
*
|
2015-10-07 00:00:37 +08:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2015-06-16 22:25:37 +08:00
|
|
|
*
|
2015-10-07 00:00:37 +08:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2015-06-16 22:25:37 +08:00
|
|
|
*
|
2015-10-07 00:00:37 +08:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
2015-06-16 22:25:37 +08:00
|
|
|
*/
|
|
|
|
#ifndef __BT_LOG_H
|
|
|
|
#define __BT_LOG_H
|
|
|
|
|
2016-01-23 01:38:49 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2016-04-20 22:54:07 +08:00
|
|
|
#if defined(CONFIG_BLUETOOTH_DEBUG_MONITOR)
|
2016-04-27 22:57:03 +08:00
|
|
|
#include <stdio.h>
|
2016-04-20 22:54:07 +08:00
|
|
|
|
|
|
|
/* 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
|
|
|
|
|
|
|
|
void bt_log(int prio, const char *fmt, ...);
|
|
|
|
|
|
|
|
#define BT_DBG(fmt, ...) bt_log(BT_LOG_DBG, "%s (%p): " fmt, \
|
|
|
|
__func__, sys_thread_self_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__)
|
|
|
|
#define BT_ASSERT(cond) if (!(cond)) { \
|
|
|
|
BT_ERR("assert: '" #cond "' failed"); \
|
|
|
|
}
|
|
|
|
/* Enabling debug increases stack size requirement considerably */
|
|
|
|
#define BT_STACK_DEBUG_EXTRA 512
|
|
|
|
|
2016-04-27 22:57:03 +08:00
|
|
|
#elif defined(CONFIG_BLUETOOTH_DEBUG_LOG)
|
2016-04-20 22:54:07 +08:00
|
|
|
|
|
|
|
#include <nanokernel.h>
|
2016-04-27 22:57:03 +08:00
|
|
|
#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__)
|
2015-07-07 17:07:50 +08:00
|
|
|
#define BT_ASSERT(cond) if (!(cond)) { \
|
2015-12-08 18:19:52 +08:00
|
|
|
BT_ERR("assert: '" #cond "' failed"); \
|
2015-07-07 17:07:50 +08:00
|
|
|
}
|
2015-12-15 16:23:59 +08:00
|
|
|
/* Enabling debug increases stack size requirement considerably */
|
|
|
|
#define BT_STACK_DEBUG_EXTRA 512
|
2016-04-20 22:54:07 +08:00
|
|
|
|
2015-06-16 22:25:37 +08:00
|
|
|
#else
|
2016-04-20 22:54:07 +08:00
|
|
|
|
2015-06-16 22:25:37 +08:00
|
|
|
#define BT_DBG(fmt, ...)
|
|
|
|
#define BT_ERR(fmt, ...)
|
|
|
|
#define BT_WARN(fmt, ...)
|
|
|
|
#define BT_INFO(fmt, ...)
|
2015-07-07 17:07:50 +08:00
|
|
|
#define BT_ASSERT(cond)
|
2015-12-15 16:23:59 +08:00
|
|
|
#define BT_STACK_DEBUG_EXTRA 0
|
2016-04-20 22:54:07 +08:00
|
|
|
|
|
|
|
#endif
|
2015-06-16 22:25:37 +08:00
|
|
|
|
2015-12-15 16:23:59 +08:00
|
|
|
#define BT_STACK(name, size) \
|
|
|
|
char __stack name[(size) + BT_STACK_DEBUG_EXTRA]
|
|
|
|
#define BT_STACK_NOINIT(name, size) \
|
|
|
|
char __noinit __stack name[(size) + BT_STACK_DEBUG_EXTRA]
|
|
|
|
|
2016-01-23 01:38:49 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-06-16 22:25:37 +08:00
|
|
|
#endif /* __BT_LOG_H */
|