aboutsummaryrefslogtreecommitdiffstats
path: root/src/util.h
diff options
context:
space:
mode:
authorLouis Burda <quent.burda@gmail.com>2022-11-20 16:35:30 +0100
committerLouis Burda <quent.burda@gmail.com>2022-11-20 16:35:44 +0100
commit570c88be0e06de5a36c8af0de7b112e9509325df (patch)
tree4c5d4a9f36db5cf6e920d06104f4be66fa2a1766 /src/util.h
parent5c2cb697aa8d03eed27b45f8dc67957c45a3d722 (diff)
downloadsxkbd-570c88be0e06de5a36c8af0de7b112e9509325df.tar.gz
sxkbd-570c88be0e06de5a36c8af0de7b112e9509325df.zip
Add CDC stdio driver and logging + panic handlers
Diffstat (limited to 'src/util.h')
-rw-r--r--src/util.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/util.h b/src/util.h
new file mode 100644
index 0000000..e413883
--- /dev/null
+++ b/src/util.h
@@ -0,0 +1,26 @@
+#pragma once
+
+#include <stdbool.h>
+#include <stdarg.h>
+
+#define ERR(...) stdio_log(LOG_ERR, __VA_ARGS__)
+#define WARN(...) stdio_log(LOG_WARN, __VA_ARGS__)
+#define INFO(...) stdio_log(LOG_INFO, __VA_ARGS__)
+#define DEBUG(...) stdio_log(LOG_DEBUG, __VA_ARGS__)
+#define PANIC(...) blink_panic(__VA_ARGS__);
+#define ASSERT(cond) blink_panic("Assertion failed: (%s) in %s:%i", \
+ #cond, __FILE__, __LINE__)
+
+enum {
+ LOG_NONE,
+ LOG_ERR,
+ LOG_WARN,
+ LOG_INFO,
+ LOG_DEBUG
+};
+
+void stdio_log(int loglevel, const char *fmtstr, ...);
+
+void blink_panic(const char *fmtstr, ...);
+
+extern int loglevel;