summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--hcid/hcid.h3
-rw-r--r--hcid/logging.c21
-rw-r--r--hcid/main.c2
3 files changed, 26 insertions, 0 deletions
diff --git a/hcid/hcid.h b/hcid/hcid.h
index 93f55bee..f3e3ce47 100644
--- a/hcid/hcid.h
+++ b/hcid/hcid.h
@@ -177,6 +177,9 @@ void info(const char *format, ...);
void error(const char *format, ...);
void debug(const char *format, ...);
+void enable_debug();
+void disable_debug();
+
static inline int find_conn(int dd, int dev_id, long arg)
{
struct hci_conn_list_req *cl;
diff --git a/hcid/logging.c b/hcid/logging.c
index 3b31366a..e478a60e 100644
--- a/hcid/logging.c
+++ b/hcid/logging.c
@@ -32,12 +32,16 @@
#include "hcid.h"
+static volatile int debug_enabled = 0;
+
void info(const char *format, ...)
{
va_list ap;
va_start(ap, format);
+
vsyslog(LOG_INFO, format, ap);
+
va_end(ap);
}
@@ -46,7 +50,9 @@ void error(const char *format, ...)
va_list ap;
va_start(ap, format);
+
vsyslog(LOG_ERR, format, ap);
+
va_end(ap);
}
@@ -54,7 +60,22 @@ void debug(const char *format, ...)
{
va_list ap;
+ if (!debug_enabled)
+ return;
+
va_start(ap, format);
+
vsyslog(LOG_DEBUG, format, ap);
+
va_end(ap);
}
+
+void enable_debug()
+{
+ debug_enabled = 1;
+}
+
+void disable_debug()
+{
+ debug_enabled = 0;
+}
diff --git a/hcid/main.c b/hcid/main.c
index 0fabed40..9deeccb2 100644
--- a/hcid/main.c
+++ b/hcid/main.c
@@ -630,6 +630,8 @@ int main(int argc, char *argv[], char *env[])
sigaction(SIGCHLD, &sa, NULL);
sigaction(SIGPIPE, &sa, NULL);
+ enable_debug();
+
/* Create and bind HCI socket */
if ((hcid.sock = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI)) < 0) {
syslog(LOG_ERR, "Can't open HCI socket: %s (%d)",