@@ -179,6 +179,18 @@ void __btd_log_init(const char *debug, int detach)
info("Bluetooth daemon %s", VERSION);
}
+bool __btd_log_is_enabled(const char *file)
+{
+ struct btd_debug_desc *desc;
+
+ for (desc = __start___debug; desc < __stop___debug; desc++) {
+ if (desc->file && g_pattern_match_simple(file, desc->file))
+ return desc->flags & BTD_DEBUG_FLAG_PRINT;
+ }
+
+ return false;
+}
+
void __btd_log_cleanup(void)
{
closelog();
@@ -9,6 +9,7 @@
*/
#include <stdint.h>
+#include <stdbool.h>
void info(const char *format, ...) __attribute__((format(printf, 1, 2)));
@@ -27,6 +28,7 @@ void btd_debug(uint16_t index, const char *format, ...)
void __btd_log_init(const char *debug, int detach);
void __btd_log_cleanup(void);
void __btd_toggle_debug(void);
+bool __btd_log_is_enabled(const char *file);
struct btd_debug_desc {
const char *file;
@@ -38,6 +40,15 @@ struct btd_debug_desc {
void __btd_enable_debug(struct btd_debug_desc *start,
struct btd_debug_desc *stop);
+/* DBG_IS_ENABLED:
+ *
+ * Simple macro that can be used to check if debug has been enabled for the
+ * __FILE__.
+ * Note: This does a lookup thus why it was not used by the likes of
+ * DBG/DBG_IDX which loads it directly from section("__debug").
+ */
+#define DBG_IS_ENABLED() __btd_log_is_enabled(__FILE__)
+
/**
* DBG:
* @fmt: format string
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> This introduces DBG_IS_ENABLE macro which can be used to check if BTD_DEBUG_FLAG_PRINT has been enabled for the current file. --- src/log.c | 12 ++++++++++++ src/log.h | 11 +++++++++++ 2 files changed, 23 insertions(+)