You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ja...@apache.org on 2025/09/01 08:38:53 UTC
(mynewt-nimble) 01/03: nuttx/nimble_npl_os_log.h: fix log level config from Kconfig
This is an automated email from the ASF dual-hosted git repository.
janc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git
commit 3f9d551d1cdda534cf6982a847a44dd079547c3a
Author: raiden00pl <ra...@railab.me>
AuthorDate: Sat Aug 23 10:41:03 2025 +0200
nuttx/nimble_npl_os_log.h: fix log level config from Kconfig
The log messages control was broken since:
da4e2f0f12859079f1bde47cbd69f39026c3cc73.
All log messages were printed. With this change we can configure the log
level from Kconfig again.
Signed-off-by: raiden00pl <ra...@railab.me>
---
.../npl/nuttx/include/nimble/nimble_npl_os_log.h | 53 ++++++++++++++++------
1 file changed, 40 insertions(+), 13 deletions(-)
diff --git a/porting/npl/nuttx/include/nimble/nimble_npl_os_log.h b/porting/npl/nuttx/include/nimble/nimble_npl_os_log.h
index 24315a21a..01220b805 100644
--- a/porting/npl/nuttx/include/nimble/nimble_npl_os_log.h
+++ b/porting/npl/nuttx/include/nimble/nimble_npl_os_log.h
@@ -20,18 +20,45 @@
#ifndef _NIMBLE_NPL_OS_LOG_H_
#define _NIMBLE_NPL_OS_LOG_H_
-#include <stdarg.h>
-#include <stdio.h>
-
-/* Example on how to use macro to generate module logging functions */
-#define BLE_NPL_LOG_IMPL(lvl) \
- static inline void _BLE_NPL_LOG_CAT(BLE_NPL_LOG_MODULE, \
- _BLE_NPL_LOG_CAT(_, lvl))(const char *fmt, ...)\
- { \
- va_list args; \
- va_start(args, fmt); \
- vprintf(fmt, args); \
- va_end(args); \
- }
+#include <nuttx/config.h>
+#include <debug.h>
+
+/* Debug log level configurable from Kconfig */
+
+#ifdef CONFIG_NIMBLE_DEBUG_ERROR
+#define nimble_err _err
+#else
+#define nimble_err _none
+#endif
+
+#ifdef CONFIG_NIMBLE_DEBUG_WARN
+#define nimble_warn _warn
+#else
+#define nimble_warn _none
+#endif
+
+#ifdef CONFIG_NIMBLE_DEBUG_INFO
+#define nimble_info _info
+#else
+#define nimble_info _none
+#endif
+
+#define DFLT_LOG_DEBUG(msg, ...) nimble_info(msg, ##__VA_ARGS__)
+#define DFLT_LOG_INFO(msg, ...) nimble_info(msg, ##__VA_ARGS__)
+#define DFLT_LOG_WARN(msg, ...) nimble_warn(msg, ##__VA_ARGS__)
+#define DFLT_LOG_ERROR(msg, ...) nimble_err(msg, ##__VA_ARGS__)
+#define DFLT_LOG_CRITICAL(msg, ...) nimble_err(msg, ##__VA_ARGS__)
+
+#define BLE_HS_LOG_DEBUG(msg, ...) nimble_info(msg, ##__VA_ARGS__)
+#define BLE_HS_LOG_INFO(msg, ...) nimble_info(msg, ##__VA_ARGS__)
+#define BLE_HS_LOG_WARN(msg, ...) nimble_warn(msg, ##__VA_ARGS__)
+#define BLE_HS_LOG_ERROR(msg, ...) nimble_err(msg, ##__VA_ARGS__)
+#define BLE_HS_LOG_CRITICAL(msg, ...) nimble_err(msg, ##__VA_ARGS__)
+
+#define BLE_EATT_LOG_DEBUG(msg, ...) nimble_info(msg, ##__VA_ARGS__)
+#define BLE_EATT_LOG_INFO(msg, ...) nimble_info(msg, ##__VA_ARGS__)
+#define BLE_EATT_LOG_WARN(msg, ...) nimble_warn(msg, ##__VA_ARGS__)
+#define BLE_EATT_LOG_ERROR(msg, ...) nimble_err(msg, ##__VA_ARGS__)
+#define BLE_EATT_LOG_CRITICAL(msg, ...) nimble_err(msg, ##__VA_ARGS__)
#endif /* _NIMBLE_NPL_OS_LOG_H_ */