From a476163c9d9ee1c1c295ce3f9bc8858d33d51b92 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Thu, 9 Mar 2006 19:43:40 +0000 Subject: Make debug messages optional, but enable it by default --- hcid/logging.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'hcid/logging.c') 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; +} -- cgit