2020-03-30 01:44:20 +02:00
|
|
|
/*
|
|
|
|
* NimBLELog.h
|
|
|
|
*
|
|
|
|
* Created: on Feb 24 2020
|
|
|
|
* Author H2zero
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#ifndef MAIN_NIMBLELOG_H_
|
|
|
|
#define MAIN_NIMBLELOG_H_
|
2021-03-28 22:47:30 +02:00
|
|
|
|
2021-09-07 05:14:43 +02:00
|
|
|
#include "nimconfig.h"
|
2021-03-28 22:47:30 +02:00
|
|
|
|
2020-03-30 01:44:20 +02:00
|
|
|
#if defined(CONFIG_BT_ENABLED)
|
|
|
|
|
2021-09-07 05:14:43 +02:00
|
|
|
#if defined(CONFIG_NIMBLE_CPP_IDF) // using esp-idf
|
|
|
|
|
|
|
|
#include "esp_log.h"
|
|
|
|
|
|
|
|
#define NIMBLE_LOGE(tag, format, ...) ESP_LOGE(tag, format, ##__VA_ARGS__)
|
|
|
|
#define NIMBLE_LOGW(tag, format, ...) ESP_LOGW(tag, format, ##__VA_ARGS__)
|
|
|
|
#define NIMBLE_LOGI(tag, format, ...) ESP_LOGI(tag, format, ##__VA_ARGS__)
|
|
|
|
#define NIMBLE_LOGD(tag, format, ...) ESP_LOGD(tag, format, ##__VA_ARGS__)
|
|
|
|
#define NIMBLE_LOGC(tag, format, ...) ESP_LOGE(tag, format, ##__VA_ARGS__)
|
|
|
|
|
|
|
|
#else // using Arduino
|
|
|
|
|
|
|
|
#include "nimble/porting/nimble/include/syscfg/syscfg.h"
|
|
|
|
#include "nimble/console/console.h"
|
2020-03-30 01:44:20 +02:00
|
|
|
|
2020-05-14 06:03:56 +02:00
|
|
|
// If Arduino is being used, strip out the colors and ignore log printing below ui setting.
|
|
|
|
// Note: because CONFIG_LOG_DEFAULT_LEVEL is set at ERROR in Arduino we must use MODLOG_DFLT(ERROR
|
2020-03-30 01:44:20 +02:00
|
|
|
// otherwise no messages will be printed above that level.
|
2021-03-28 22:47:30 +02:00
|
|
|
|
2022-01-14 17:58:37 +01:00
|
|
|
#ifndef CONFIG_NIMBLE_CPP_DEBUG_LEVEL
|
2021-09-07 05:14:43 +02:00
|
|
|
#if defined(ARDUINO_ARCH_ESP32) && defined(CORE_DEBUG_LEVEL)
|
2022-01-14 17:58:37 +01:00
|
|
|
#define CONFIG_NIMBLE_CPP_DEBUG_LEVEL CORE_DEBUG_LEVEL
|
2021-09-07 05:14:43 +02:00
|
|
|
#else
|
2022-01-14 17:58:37 +01:00
|
|
|
#define CONFIG_NIMBLE_CPP_DEBUG_LEVEL 0
|
2021-09-07 05:14:43 +02:00
|
|
|
#endif
|
2020-04-14 03:13:51 +02:00
|
|
|
#endif
|
2020-03-30 01:44:20 +02:00
|
|
|
|
2022-01-14 17:58:37 +01:00
|
|
|
#if CONFIG_NIMBLE_CPP_DEBUG_LEVEL >= 4
|
2021-09-07 05:14:43 +02:00
|
|
|
#define NIMBLE_LOGD( tag, format, ... ) console_printf("D %s: "#format"\n",tag,##__VA_ARGS__)
|
2020-03-30 01:44:20 +02:00
|
|
|
#else
|
2020-06-29 00:50:46 +02:00
|
|
|
#define NIMBLE_LOGD( tag, format, ... ) (void)tag
|
2020-03-30 01:44:20 +02:00
|
|
|
#endif
|
|
|
|
|
2022-01-14 17:58:37 +01:00
|
|
|
#if CONFIG_NIMBLE_CPP_DEBUG_LEVEL >= 3
|
2021-09-07 05:14:43 +02:00
|
|
|
#define NIMBLE_LOGI( tag, format, ... ) console_printf("I %s: "#format"\n",tag,##__VA_ARGS__)
|
2020-03-30 01:44:20 +02:00
|
|
|
#else
|
2020-06-29 00:50:46 +02:00
|
|
|
#define NIMBLE_LOGI( tag, format, ... ) (void)tag
|
2020-03-30 01:44:20 +02:00
|
|
|
#endif
|
|
|
|
|
2022-01-14 17:58:37 +01:00
|
|
|
#if CONFIG_NIMBLE_CPP_DEBUG_LEVEL >= 2
|
2021-09-07 05:14:43 +02:00
|
|
|
#define NIMBLE_LOGW( tag, format, ... ) console_printf("W %s: "#format"\n",tag,##__VA_ARGS__)
|
2020-03-30 01:44:20 +02:00
|
|
|
#else
|
2020-06-29 00:50:46 +02:00
|
|
|
#define NIMBLE_LOGW( tag, format, ... ) (void)tag
|
2020-03-30 01:44:20 +02:00
|
|
|
#endif
|
|
|
|
|
2022-01-14 17:58:37 +01:00
|
|
|
#if CONFIG_NIMBLE_CPP_DEBUG_LEVEL >= 1
|
2021-09-07 05:14:43 +02:00
|
|
|
#define NIMBLE_LOGE( tag, format, ... ) console_printf("E %s: "#format"\n",tag,##__VA_ARGS__)
|
|
|
|
#define NIMBLE_LOGC( tag, format, ... ) console_printf("CRIT %s: "#format"\n",tag,##__VA_ARGS__)
|
2020-03-30 01:44:20 +02:00
|
|
|
#else
|
2020-06-29 00:50:46 +02:00
|
|
|
#define NIMBLE_LOGE( tag, format, ... ) (void)tag
|
2021-09-07 05:14:43 +02:00
|
|
|
#define NIMBLE_LOGC( tag, format, ... ) (void)tag
|
2020-03-30 01:44:20 +02:00
|
|
|
#endif
|
|
|
|
|
2021-03-28 22:47:30 +02:00
|
|
|
|
2020-03-30 01:44:20 +02:00
|
|
|
|
2021-09-07 05:14:43 +02:00
|
|
|
#endif /* CONFIG_NIMBLE_CPP_IDF */
|
|
|
|
#endif /* CONFIG_BT_ENABLED */
|
|
|
|
#endif /* MAIN_NIMBLELOG_H_ */
|