summaryrefslogtreecommitdiff
path: root/src/runtime/c/gu/log.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/runtime/c/gu/log.h')
-rw-r--r--src/runtime/c/gu/log.h65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/runtime/c/gu/log.h b/src/runtime/c/gu/log.h
new file mode 100644
index 000000000..ec9ecdf75
--- /dev/null
+++ b/src/runtime/c/gu/log.h
@@ -0,0 +1,65 @@
+#ifndef GU_LOG_H_
+#define GU_LOG_H_
+
+#include <stdarg.h>
+
+typedef enum GuLogKind {
+ GU_LOG_KIND_ENTER,
+ GU_LOG_KIND_EXIT,
+ GU_LOG_KIND_DEBUG,
+ GU_LOG_KIND_ERROR
+} GuLogKind;
+
+void
+gu_log_full(GuLogKind kind, const char* func, const char* file, int line,
+ const char* fmt, ...);
+
+
+void
+gu_log_full_v(GuLogKind kind, const char* func, const char* file, int line,
+ const char* fmt, va_list args);
+
+
+#ifndef NDEBUG
+
+#define gu_logv(kind_, fmt_, args_) \
+ gu_log_full_v(kind_, __func__, __FILE__, __LINE__, fmt_, args_)
+
+#define gu_log(kind_, ...) \
+ gu_log_full(kind_, __func__, __FILE__, __LINE__, __VA_ARGS__)
+
+#else
+
+static inline void
+gu_logv(GuLogKind kind, const char* fmt, va_list args)
+{
+ (void) kind;
+ (void) fmt;
+ (void) args;
+}
+
+static inline void
+gu_log(GuLogKind kind, const char* fmt, ...)
+{
+ (void) kind;
+ (void) fmt;
+}
+
+#endif
+
+
+
+
+#define gu_enter(...) \
+ gu_log(GU_LOG_KIND_ENTER, __VA_ARGS__)
+
+#define gu_exit(...) \
+ gu_log(GU_LOG_KIND_EXIT, __VA_ARGS__)
+
+#define gu_debug(...) \
+ gu_log(GU_LOG_KIND_DEBUG, __VA_ARGS__)
+
+#define gu_debugv(kind_, fmt_, args_) \
+ gu_logv(GU_LOG_KIND_DEBUG, fmt_, args_)
+
+#endif // GU_LOG_H_