|
14 | 14 | * See the License for the specific language governing permissions and |
15 | 15 | * limitations under the License. |
16 | 16 | */ |
17 | | -#ifndef MAIN_NIMBLELOG_H_ |
18 | | -#define MAIN_NIMBLELOG_H_ |
19 | 17 |
|
20 | | -#include "nimconfig.h" |
| 18 | +#ifndef NIMBLE_CPP_LOG_H_ |
| 19 | +#define NIMBLE_CPP_LOG_H_ |
21 | 20 |
|
| 21 | +#include "nimconfig.h" |
22 | 22 | #if defined(CONFIG_BT_ENABLED) |
23 | 23 |
|
24 | | -#if defined(CONFIG_NIMBLE_CPP_IDF) // using esp-idf |
| 24 | +# if defined(CONFIG_NIMBLE_CPP_IDF) |
25 | 25 | # include "esp_log.h" |
26 | 26 | # include "console/console.h" |
27 | 27 | # ifndef CONFIG_NIMBLE_CPP_LOG_LEVEL |
28 | | -# define CONFIG_NIMBLE_CPP_LOG_LEVEL 0 |
| 28 | +# define CONFIG_NIMBLE_CPP_LOG_LEVEL 0 |
29 | 29 | # endif |
30 | 30 |
|
31 | | -# define NIMBLE_CPP_LOG_PRINT(level, tag, format, ...) do { \ |
32 | | - if (CONFIG_NIMBLE_CPP_LOG_LEVEL >= level) \ |
33 | | - ESP_LOG_LEVEL_LOCAL(level, tag, format, ##__VA_ARGS__); \ |
34 | | - } while(0) |
35 | | - |
36 | | -# define NIMBLE_LOGD(tag, format, ...) \ |
37 | | - NIMBLE_CPP_LOG_PRINT(ESP_LOG_DEBUG, tag, format, ##__VA_ARGS__) |
38 | | - |
39 | | -# define NIMBLE_LOGI(tag, format, ...) \ |
40 | | - NIMBLE_CPP_LOG_PRINT(ESP_LOG_INFO, tag, format, ##__VA_ARGS__) |
| 31 | +# define NIMBLE_CPP_LOG_PRINT(level, tag, format, ...) \ |
| 32 | + do { \ |
| 33 | + if (CONFIG_NIMBLE_CPP_LOG_LEVEL >= level) ESP_LOG_LEVEL_LOCAL(level, tag, format, ##__VA_ARGS__); \ |
| 34 | + } while (0) |
41 | 35 |
|
42 | | -# define NIMBLE_LOGW(tag, format, ...) \ |
43 | | - NIMBLE_CPP_LOG_PRINT(ESP_LOG_WARN, tag, format, ##__VA_ARGS__) |
| 36 | +# define NIMBLE_LOGD(tag, format, ...) NIMBLE_CPP_LOG_PRINT(ESP_LOG_DEBUG, tag, format, ##__VA_ARGS__) |
| 37 | +# define NIMBLE_LOGI(tag, format, ...) NIMBLE_CPP_LOG_PRINT(ESP_LOG_INFO, tag, format, ##__VA_ARGS__) |
| 38 | +# define NIMBLE_LOGW(tag, format, ...) NIMBLE_CPP_LOG_PRINT(ESP_LOG_WARN, tag, format, ##__VA_ARGS__) |
| 39 | +# define NIMBLE_LOGE(tag, format, ...) NIMBLE_CPP_LOG_PRINT(ESP_LOG_ERROR, tag, format, ##__VA_ARGS__) |
44 | 40 |
|
45 | | -# define NIMBLE_LOGE(tag, format, ...) \ |
46 | | - NIMBLE_CPP_LOG_PRINT(ESP_LOG_ERROR, tag, format, ##__VA_ARGS__) |
47 | | - |
48 | | -#else // using Arduino |
| 41 | +# else |
49 | 42 | # include "nimble/porting/nimble/include/syscfg/syscfg.h" |
50 | 43 | # include "nimble/console/console.h" |
51 | 44 | # ifndef CONFIG_NIMBLE_CPP_LOG_LEVEL |
52 | | -# if defined(ARDUINO_ARCH_ESP32) && defined(CORE_DEBUG_LEVEL) |
53 | | -# define CONFIG_NIMBLE_CPP_LOG_LEVEL CORE_DEBUG_LEVEL |
54 | | -# else |
55 | | -# define CONFIG_NIMBLE_CPP_LOG_LEVEL 0 |
56 | | -# endif |
| 45 | +# if defined(ARDUINO_ARCH_ESP32) && defined(CORE_DEBUG_LEVEL) |
| 46 | +# define CONFIG_NIMBLE_CPP_LOG_LEVEL CORE_DEBUG_LEVEL |
| 47 | +# else |
| 48 | +# define CONFIG_NIMBLE_CPP_LOG_LEVEL 0 |
| 49 | +# endif |
57 | 50 | # endif |
58 | 51 |
|
59 | 52 | # if CONFIG_NIMBLE_CPP_LOG_LEVEL >= 4 |
60 | | -# define NIMBLE_LOGD( tag, format, ... ) console_printf("D %s: " format "\n", tag, ##__VA_ARGS__) |
| 53 | +# define NIMBLE_LOGD(tag, format, ...) console_printf("D %s: " format "\n", tag, ##__VA_ARGS__) |
61 | 54 | # else |
62 | | -# define NIMBLE_LOGD( tag, format, ... ) (void)tag |
| 55 | +# define NIMBLE_LOGD(tag, format, ...) (void)tag |
63 | 56 | # endif |
64 | 57 |
|
65 | 58 | # if CONFIG_NIMBLE_CPP_LOG_LEVEL >= 3 |
66 | | -# define NIMBLE_LOGI( tag, format, ... ) console_printf("I %s: " format "\n", tag, ##__VA_ARGS__) |
| 59 | +# define NIMBLE_LOGI(tag, format, ...) console_printf("I %s: " format "\n", tag, ##__VA_ARGS__) |
67 | 60 | # else |
68 | | -# define NIMBLE_LOGI( tag, format, ... ) (void)tag |
| 61 | +# define NIMBLE_LOGI(tag, format, ...) (void)tag |
69 | 62 | # endif |
70 | 63 |
|
71 | 64 | # if CONFIG_NIMBLE_CPP_LOG_LEVEL >= 2 |
72 | | -# define NIMBLE_LOGW( tag, format, ... ) console_printf("W %s: " format "\n", tag, ##__VA_ARGS__) |
| 65 | +# define NIMBLE_LOGW(tag, format, ...) console_printf("W %s: " format "\n", tag, ##__VA_ARGS__) |
73 | 66 | # else |
74 | | -# define NIMBLE_LOGW( tag, format, ... ) (void)tag |
| 67 | +# define NIMBLE_LOGW(tag, format, ...) (void)tag |
75 | 68 | # endif |
76 | 69 |
|
77 | 70 | # if CONFIG_NIMBLE_CPP_LOG_LEVEL >= 1 |
78 | | -# define NIMBLE_LOGE( tag, format, ... ) console_printf("E %s: " format "\n", tag, ##__VA_ARGS__) |
| 71 | +# define NIMBLE_LOGE(tag, format, ...) console_printf("E %s: " format "\n", tag, ##__VA_ARGS__) |
79 | 72 | # else |
80 | | -# define NIMBLE_LOGE( tag, format, ... ) (void)tag |
| 73 | +# define NIMBLE_LOGE(tag, format, ...) (void)tag |
81 | 74 | # endif |
82 | 75 |
|
83 | | -#endif /* CONFIG_NIMBLE_CPP_IDF */ |
84 | | - |
85 | | -#define NIMBLE_LOGC( tag, format, ... ) console_printf("CRIT %s: " format "\n", tag, ##__VA_ARGS__) |
86 | | - |
87 | | -#endif /* CONFIG_BT_ENABLED */ |
88 | | -#endif /* MAIN_NIMBLELOG_H_ */ |
| 76 | +# endif /* CONFIG_NIMBLE_CPP_IDF */ |
| 77 | +#endif /* CONFIG_BT_ENABLED */ |
| 78 | +#endif /* NIMBLE_CPP_LOG_H_ */ |
0 commit comments