aboutsummaryrefslogtreecommitdiff
path: root/teensy/teensy_log.h
diff options
context:
space:
mode:
authoriamcheeseman <[email protected]>2026-05-10 00:28:14 -0400
committeriamcheeseman <[email protected]>2026-05-10 00:28:14 -0400
commit576bd27e11ec70bdbd1b9a644d2e227b57586337 (patch)
tree2dc41e3f88bb95568f73ee372fc35512afcbcf9b /teensy/teensy_log.h
parent9ed5698b3c74c7ce1784d3bebe2aa73d5a0c319d (diff)
i ain't splitting alla this up
Diffstat (limited to 'teensy/teensy_log.h')
-rw-r--r--teensy/teensy_log.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/teensy/teensy_log.h b/teensy/teensy_log.h
new file mode 100644
index 0000000..825ce55
--- /dev/null
+++ b/teensy/teensy_log.h
@@ -0,0 +1,47 @@
+#ifndef TEENSY_LOG_H_
+#define TEENSY_LOG_H_
+
+#include <stdio.h>
+#include <stdlib.h>
+
+// Don't include common.h, because this should be included there
+
+#define ty_log_info(fmt, ...) \
+ ty_log_msg(stdout, __FILE__, __LINE__, "info", fmt, ## __VA_ARGS__)
+#define ty_log_warn(fmt, ...) \
+ ty_log_msg(stderr, __FILE__, __LINE__, "warn", fmt, ## __VA_ARGS__)
+#define ty_log_err(fmt, ...) \
+ ty_log_msg(stderr, __FILE__, __LINE__, "error", fmt, ## __VA_ARGS__)
+#define ty_log_fatal(ec, fmt, ...) \
+ (ty_log_msg(stderr, __FILE__, __LINE__, "fatal", fmt, ## __VA_ARGS__), \
+ exit(ec))
+#define ty_olog(fmt, ...) \
+ _log_plain(stdout, fmt, ## __VA_ARGS__)
+#define ty_elog(fmt, ...) \
+ _log_plain(stderr, fmt, ## __VA_ARGS__)
+
+// To be passed as the exit code to log_fatal()
+
+// General errors
+#define TY_ERR_MEM 0x01
+#define TY_ERR_IO 0x02
+#define TY_ERR_MEM_LEAK 0x03
+#define TY_PLATFORM_ERR 0x04
+
+// Rendering errors
+#define TY_ERR_GLFW_INIT 0x30
+#define TY_ERR_RENDERER_NOT_INIT 0x31
+#define TY_ERR_RENDER_OOB 0x32 // Render out-of-bounds
+
+void ty_log_msg(
+ FILE *file,
+ const char *src_name,
+ int src_line,
+ const char *type,
+ const char *fmt,
+ ...
+);
+
+void _ty_log_plain(FILE *file, const char *fmt, ...);
+
+#endif // TEENSY_LOG_H_