diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2006-03-09 19:43:40 +0000 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2006-03-09 19:43:40 +0000 |
commit | a476163c9d9ee1c1c295ce3f9bc8858d33d51b92 (patch) | |
tree | bfced2faad249113fd78b4b4d79bdf11bb9242fe | |
parent | 0df89f0370532854e929d68ef2836a84693acd65 (diff) |
Make debug messages optional, but enable it by default
-rw-r--r-- | hcid/hcid.h | 3 | ||||
-rw-r--r-- | hcid/logging.c | 21 | ||||
-rw-r--r-- | hcid/main.c | 2 |
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)", |