aboutsummaryrefslogtreecommitdiff
path: root/debug.c
diff options
context:
space:
mode:
Diffstat (limited to 'debug.c')
-rw-r--r--debug.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/debug.c b/debug.c
new file mode 100644
index 0000000..125974a
--- /dev/null
+++ b/debug.c
@@ -0,0 +1,21 @@
+#include <stdio.h>
+#include <stdarg.h>
+
+#include "debug.h"
+#include "options.h"
+#include "output.h"
+
+void
+debug_(int level, char *file, int line, char *func, char *fmt, ...) {
+ char buf[1024];
+ va_list args;
+
+ if (opt_d < level) {
+ return;
+ }
+ va_start(args, fmt);
+ vsnprintf(buf, 1024, fmt, args);
+ va_end(args);
+
+ output_line(NULL, "DEBUG: %s:%d: %s(): %s", file, line, func, buf);
+}