diff --git a/src/log.c b/src/log.c
index f5a281a..0442c26 100644
--- a/src/log.c
+++ b/src/log.c
}
}
-static void logging_log(int priority, const char *format, va_list ap)
+static void logging_log(uint16_t index, int priority,
+ const char *format, va_list ap)
{
char *ident = "bluetoothd";
uint8_t ident_len = strlen(ident) + 1;
len = strlen(str) + 1;
hdr.opcode = cpu_to_le16(0x0000);
- hdr.index = cpu_to_le16(0xffff);
+ hdr.index = cpu_to_le16(index);
hdr.len = cpu_to_le16(2 + ident_len + len);
hdr.priority = priority;
hdr.ident_len = ident_len;
free(str);
}
-void info(const char *format, ...)
+void error(const char *format, ...)
{
va_list ap;
va_start(ap, format);
- vsyslog(LOG_INFO, format, ap);
+ vsyslog(LOG_ERR, format, ap);
va_end(ap);
if (logging_fd < 0)
return;
va_start(ap, format);
- logging_log(LOG_INFO, format, ap);
+ logging_log(HCI_DEV_NONE, LOG_ERR, format, ap);
va_end(ap);
}
return;
va_start(ap, format);
- logging_log(LOG_WARNING, format, ap);
+ logging_log(HCI_DEV_NONE, LOG_WARNING, format, ap);
va_end(ap);
}
-void error(const char *format, ...)
+void info(const char *format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ vsyslog(LOG_INFO, format, ap);
+ va_end(ap);
+
+ if (logging_fd < 0)
+ return;
+
+ va_start(ap, format);
+ logging_log(HCI_DEV_NONE, LOG_INFO, format, ap);
+ va_end(ap);
+}
+
+void btd_error(uint16_t index, const char *format, ...)
{
va_list ap;
return;
va_start(ap, format);
- logging_log(LOG_ERR, format, ap);
+ logging_log(index, LOG_ERR, format, ap);
+ va_end(ap);
+}
+
+void btd_warn(uint16_t index, const char *format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ vsyslog(LOG_WARNING, format, ap);
+ va_end(ap);
+
+ if (logging_fd < 0)
+ return;
+
+ va_start(ap, format);
+ logging_log(index, LOG_WARNING, format, ap);
+ va_end(ap);
+}
+
+void btd_info(uint16_t index, const char *format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ vsyslog(LOG_INFO, format, ap);
+ va_end(ap);
+
+ if (logging_fd < 0)
+ return;
+
+ va_start(ap, format);
+ logging_log(index, LOG_INFO, format, ap);
va_end(ap);
}
-void btd_debug(const char *format, ...)
+void btd_debug(uint16_t index, const char *format, ...)
{
va_list ap;
return;
va_start(ap, format);
- logging_log(LOG_DEBUG, format, ap);
+ logging_log(index, LOG_DEBUG, format, ap);
va_end(ap);
}
diff --git a/src/log.h b/src/log.h
index bf9eac2..f40fb31 100644
--- a/src/log.h
+++ b/src/log.h
*
*/
-void info(const char *format, ...) __attribute__((format(printf, 1, 2)));
-void warn(const char *format, ...) __attribute__((format(printf, 1, 2)));
+#include <stdint.h>
+
void error(const char *format, ...) __attribute__((format(printf, 1, 2)));
+void warn(const char *format, ...) __attribute__((format(printf, 1, 2)));
+void info(const char *format, ...) __attribute__((format(printf, 1, 2)));
-void btd_debug(const char *format, ...) __attribute__((format(printf, 1, 2)));
+void btd_error(uint16_t index, const char *format, ...)
+ __attribute__((format(printf, 2, 3)));
+void btd_warn(uint16_t index, const char *format, ...)
+ __attribute__((format(printf, 2, 3)));
+void btd_info(uint16_t index, const char *format, ...)
+ __attribute__((format(printf, 2, 3)));
+void btd_debug(uint16_t index, const char *format, ...)
+ __attribute__((format(printf, 2, 3)));
void __btd_log_init(const char *debug, int detach);
void __btd_log_cleanup(void);
* Simple macro around btd_debug() which also include the function
* name it is called in.
*/
-#define DBG(fmt, arg...) do { \
+#define DBG_IDX(idx, fmt, arg...) do { \
static struct btd_debug_desc __btd_debug_desc \
__attribute__((used, section("__debug"), aligned(8))) = { \
.file = __FILE__, .flags = BTD_DEBUG_FLAG_DEFAULT, \
}; \
if (__btd_debug_desc.flags & BTD_DEBUG_FLAG_PRINT) \
- btd_debug("%s:%s() " fmt, __FILE__, __func__ , ## arg); \
+ btd_debug(idx, "%s:%s() " fmt, __FILE__, __func__ , ## arg); \
} while (0)
+
+#define DBG(fmt, arg...) DBG_IDX(0xffff, fmt, ## arg)