summaryrefslogtreecommitdiff
path: root/debug.c
diff options
context:
space:
mode:
Diffstat (limited to 'debug.c')
-rw-r--r--debug.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/debug.c b/debug.c
index 22c0000..890d7a5 100644
--- a/debug.c
+++ b/debug.c
@@ -48,6 +48,10 @@ struct {
#endif
int fd;
int file_fd;
+#ifdef WITH_DBG_SYSLOG
+ const char* syslog_host;
+ int syslog_port;
+#endif
} dbg_config = { .flags = DBG_FLAG_DEFAULT, .fd = -1, .file_fd = -1 };
static void dbg_mutex_init()
@@ -114,6 +118,14 @@ dbg_status_t dbg_init(unsigned int flags, ...)
dbg_config.file_fd = open(filename, O_CREAT | O_RDWR, 0777);
}
break;
+#ifdef WITH_DBG_SYSLOG
+ case DBG_OPTION_SYSLOG_PORT:
+ dbg_config.syslog_port = va_arg(vl, int);
+ break;
+ case DBG_OPTION_SYSLOG_HOST:
+ dbg_config.syslog_host = (const char*)va_arg(vl, char*);
+ break;
+#endif
default:
status = DBG_STATUS_UNKNOWN_OPTION;
printf("option: %x\n", option);
@@ -123,6 +135,12 @@ dbg_status_t dbg_init(unsigned int flags, ...)
dbg_mutex_init();
+#ifdef WITH_DBG_SYSLOG
+ if(dbg_config.flags & DBG_FLAG_OUTPUT_TO_SYSLOG) {
+ dbg_syslog_init(dbg_config.syslog_host, dbg_config.syslog_port);
+ }
+#endif
+
err:
va_end(vl);
@@ -135,6 +153,10 @@ void dbg_close()
if(dbg_config.file_fd != -1) close(dbg_config.file_fd);
}
+#ifdef WITH_DBG_SYSLOG
+ dbg_syslog_close();
+#endif
+
dbg_mutex_close();
}
@@ -212,6 +234,10 @@ int __debug(const char *func, const int line,
dbg_output_fd(dbg_config.file_fd, buf);
}
+ if(dbg_config.flags & DBG_FLAG_OUTPUT_TO_SYSLOG) {
+ dbg_syslog_output(buf);
+ }
+
done:
dbg_mutex_unlock();