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
|
2022-01-15 03:45:48 +01:00
|
|
|
# include "esp_log.h"
|
2024-07-04 18:56:30 +02:00
|
|
|
# include "console/console.h"
|
2022-01-15 03:45:48 +01:00
|
|
|
# ifndef CONFIG_NIMBLE_CPP_LOG_LEVEL
|
|
|
|
# define CONFIG_NIMBLE_CPP_LOG_LEVEL 0
|
|
|
|
# endif
|
2021-09-07 05:14:43 +02:00
|
|
|
|
2022-01-15 03:45:48 +01:00
|
|
|
# define NIMBLE_CPP_LOG_PRINT(level, tag, format, ...) do { \
|
|
|
|
if (CONFIG_NIMBLE_CPP_LOG_LEVEL >= level) \
|
|
|
|
ESP_LOG_LEVEL_LOCAL(level, tag, format, ##__VA_ARGS__); \
|
|
|
|
} while(0)
|
2021-09-07 05:14:43 +02:00
|
|
|
|
2022-01-15 03:45:48 +01:00
|
|
|
# define NIMBLE_LOGD(tag, format, ...) \
|
|
|
|
NIMBLE_CPP_LOG_PRINT(ESP_LOG_DEBUG, tag, format, ##__VA_ARGS__)
|
2021-09-07 05:14:43 +02:00
|
|
|
|
2022-01-15 03:45:48 +01:00
|
|
|
# define NIMBLE_LOGI(tag, format, ...) \
|
|
|
|
NIMBLE_CPP_LOG_PRINT(ESP_LOG_INFO, tag, format, ##__VA_ARGS__)
|
2020-03-30 01:44:20 +02:00
|
|
|
|
2022-01-15 03:45:48 +01:00
|
|
|
# define NIMBLE_LOGW(tag, format, ...) \
|
|
|
|
NIMBLE_CPP_LOG_PRINT(ESP_LOG_WARN, tag, format, ##__VA_ARGS__)
|
2020-03-30 01:44:20 +02:00
|
|
|
|
2022-01-15 03:45:48 +01:00
|
|
|
# define NIMBLE_LOGE(tag, format, ...) \
|
|
|
|
NIMBLE_CPP_LOG_PRINT(ESP_LOG_ERROR, tag, format, ##__VA_ARGS__)
|
2020-03-30 01:44:20 +02:00
|
|
|
|
2022-01-15 03:45:48 +01:00
|
|
|
#else // using Arduino
|
|
|
|
# include "nimble/porting/nimble/include/syscfg/syscfg.h"
|
|
|
|
# include "nimble/console/console.h"
|
|
|
|
# ifndef CONFIG_NIMBLE_CPP_LOG_LEVEL
|
|
|
|
# if defined(ARDUINO_ARCH_ESP32) && defined(CORE_DEBUG_LEVEL)
|
|
|
|
# define CONFIG_NIMBLE_CPP_LOG_LEVEL CORE_DEBUG_LEVEL
|
|
|
|
# else
|
|
|
|
# define CONFIG_NIMBLE_CPP_LOG_LEVEL 0
|
|
|
|
# endif
|
|
|
|
# endif
|
|
|
|
|
|
|
|
# if CONFIG_NIMBLE_CPP_LOG_LEVEL >= 4
|
2022-01-15 20:43:17 +01:00
|
|
|
# define NIMBLE_LOGD( tag, format, ... ) console_printf("D %s: " format "\n", tag, ##__VA_ARGS__)
|
2022-01-15 03:45:48 +01:00
|
|
|
# else
|
|
|
|
# define NIMBLE_LOGD( tag, format, ... ) (void)tag
|
|
|
|
# endif
|
|
|
|
|
|
|
|
# if CONFIG_NIMBLE_CPP_LOG_LEVEL >= 3
|
2022-01-15 20:43:17 +01:00
|
|
|
# define NIMBLE_LOGI( tag, format, ... ) console_printf("I %s: " format "\n", tag, ##__VA_ARGS__)
|
2022-01-15 03:45:48 +01:00
|
|
|
# else
|
|
|
|
# define NIMBLE_LOGI( tag, format, ... ) (void)tag
|
|
|
|
# endif
|
|
|
|
|
|
|
|
# if CONFIG_NIMBLE_CPP_LOG_LEVEL >= 2
|
2022-01-15 20:43:17 +01:00
|
|
|
# define NIMBLE_LOGW( tag, format, ... ) console_printf("W %s: " format "\n", tag, ##__VA_ARGS__)
|
2022-01-15 03:45:48 +01:00
|
|
|
# else
|
|
|
|
# define NIMBLE_LOGW( tag, format, ... ) (void)tag
|
|
|
|
# endif
|
|
|
|
|
|
|
|
# if CONFIG_NIMBLE_CPP_LOG_LEVEL >= 1
|
2022-01-15 20:43:17 +01:00
|
|
|
# define NIMBLE_LOGE( tag, format, ... ) console_printf("E %s: " format "\n", tag, ##__VA_ARGS__)
|
2022-01-15 03:45:48 +01:00
|
|
|
# else
|
|
|
|
# define NIMBLE_LOGE( tag, format, ... ) (void)tag
|
|
|
|
# endif
|
2020-03-30 01:44:20 +02:00
|
|
|
|
2021-09-07 05:14:43 +02:00
|
|
|
#endif /* CONFIG_NIMBLE_CPP_IDF */
|
2024-07-04 18:56:30 +02:00
|
|
|
|
|
|
|
#define NIMBLE_LOGC( tag, format, ... ) console_printf("CRIT %s: " format "\n", tag, ##__VA_ARGS__)
|
|
|
|
|
2021-09-07 05:14:43 +02:00
|
|
|
#endif /* CONFIG_BT_ENABLED */
|
|
|
|
#endif /* MAIN_NIMBLELOG_H_ */
|