aboutsummaryrefslogtreecommitdiff
path: root/log.h
diff options
context:
space:
mode:
authorFederico Angelilli <code@fedang.net>2023-11-02 22:13:17 +0100
committerFederico Angelilli <code@fedang.net>2023-11-02 22:13:17 +0100
commit99ca49947936207276e4c97dd21201027e0ad182 (patch)
treeea0b6e56e9a50010131bcc44bdaec1ea2cdda0a3 /log.h
parent31bff49ef9c5e9ee6079e369e3b4d90c447f8d0b (diff)
Add logging functions
Diffstat (limited to 'log.h')
-rw-r--r--log.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/log.h b/log.h
new file mode 100644
index 0000000..28dbf14
--- /dev/null
+++ b/log.h
@@ -0,0 +1,27 @@
+#ifndef COMET_LOG_H
+#define COMET_LOG_H
+
+#include <stdio.h>
+
+#define DEBUG_FORMAT(format, ...) \
+ "[%s] \x1b[1mdebug\x1b[0m: " format, __func__, ## __VA_ARGS__
+
+#define INFO_FORMAT(format, ...) \
+ "[%s] \x1b[1;96minfo\x1b[0m: " format, __func__, ## __VA_ARGS__
+
+#define WARNING_FORMAT(format, ...) \
+ "[%s] \x1b[1;33mwarning\x1b[0m: " format, __func__, ## __VA_ARGS__
+
+#define ERROR_FORMAT(format, ...) \
+ "[%s] \x1b[1;31merror\x1b[0m: " format, __func__, ## __VA_ARGS__
+
+#define log_debug(...) g_debug(DEBUG_FORMAT(__VA_ARGS__))
+#define log_info(...) g_info(INFO_FORMAT(__VA_ARGS__))
+#define log_warning(...) g_warning(WARNING_FORMAT(__VA_ARGS__))
+#define log_error(...) g_error(ERROR_FORMAT(__VA_ARGS__))
+
+void log_init(GLogLevelFlags level);
+
+#endif
+
+// vim: ts=4 sw=4 et