aboutsummaryrefslogtreecommitdiff
path: root/src/log.c
diff options
context:
space:
mode:
authorMarvin Borner2023-04-17 12:37:15 +0200
committerMarvin Borner2023-04-17 12:37:15 +0200
commitc8505852fff816f8e319cb7492ff1fee55f33f23 (patch)
treefc7cb822f53605e0b5835aab8f217bddaa981554 /src/log.c
parentf8e807e657766342ae4931d77edce8f1a5d27b56 (diff)
Added logging and verbosity flag
Diffstat (limited to 'src/log.c')
-rw-r--r--src/log.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/log.c b/src/log.c
new file mode 100644
index 0000000..06c3614
--- /dev/null
+++ b/src/log.c
@@ -0,0 +1,36 @@
+// Copyright (c) 2023, Marvin Borner <dev@marvinborner.de>
+// SPDX-License-Identifier: MIT
+
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdlib.h>
+
+#include <log.h>
+
+static int debug_enabled = 0;
+
+void debug(const char *format, ...)
+{
+ if (!debug_enabled)
+ return;
+
+ va_list ap;
+ va_start(ap, format);
+ vfprintf(stderr, format, ap);
+ va_end(ap);
+}
+
+void debug_enable(int enable)
+{
+ debug_enabled = enable;
+}
+
+void fatal(const char *format, ...)
+{
+ va_list ap;
+ va_start(ap, format);
+ vfprintf(stderr, format, ap);
+ va_end(ap);
+
+ abort();
+}