diff options
Diffstat (limited to 'debug.c')
-rw-r--r-- | debug.c | 34 |
1 files changed, 24 insertions, 10 deletions
@@ -45,7 +45,11 @@ #include "debug_filter.h" #endif -struct { +#ifdef WITH_DBG_SYSLOG +#include "debug_syslog.h" +#endif + +struct dbg_config_t { unsigned int flags; #ifdef WITH_DBG_MUTEX pthread_mutex_t mutex; @@ -56,7 +60,8 @@ struct { const char* syslog_host; int syslog_port; #endif -} dbg_config = { .flags = DBG_FLAG_DEFAULT, .fd = -1, .file_fd = -1 }; +};// dbg_config;// = { .flags = DBG_FLAG_DEFAULT, .fd = -1, .file_fd = -1 }; +static struct dbg_config_t dbg_config; static void dbg_mutex_init() { @@ -103,6 +108,10 @@ dbg_status_t dbg_init(unsigned int flags, ...) dbg_config.flags = flags; + dbg_config.flags = DBG_FLAG_DEFAULT; + dbg_config.fd = -1; + dbg_config.file_fd = -1; + int end = 0; va_list vl; @@ -201,10 +210,14 @@ static int dbg_output_fd(int fd, const char *msg) char hdr[32]; dbg_create_header(hdr, sizeof(hdr)); - write(fd, hdr, strlen(hdr)); - write(fd, " ", 1); - write(fd, msg, strlen(msg)); - if(msg[strlen(msg) - 1] != '\n') write(fd, "\n", 1); + + int s = -1; + s = write(fd, hdr, strlen(hdr)); + s = write(fd, " ", 1); + s = write(fd, msg, strlen(msg)); + if(msg[strlen(msg) - 1] != '\n') { + s = write(fd, "\n", 1); + } return 0; } @@ -213,6 +226,7 @@ int __debug(const char *func, const int line, const char *ch, const char *fmt, ...) { int result = 0; + int sz; dbg_mutex_lock(); @@ -226,9 +240,9 @@ int __debug(const char *func, const int line, char buf[1024]; - int sz = snprintf(buf, sizeof(buf), - "%s:%s:%s:%d ", - debug_class_str[(unsigned)cl], ch, func, line); + sz = snprintf(buf, sizeof(buf), + "%s:%s:%s:%d ", + debug_class_str[(unsigned)cl], ch, func, line); va_list va; va_start(va, fmt); sz += vsnprintf(buf + sz, sizeof(buf) - sz, fmt, va); @@ -258,7 +272,7 @@ int __debug(const char *func, const int line, dbg_syslog_output(buf); } - done: +// done: dbg_mutex_unlock(); return result; |