src/error.c

changeset 107
a35b39abe2b2
parent 106
895f92cff6b8
--- a/src/error.c	Sat May 03 14:30:56 2025 +0200
+++ b/src/error.c	Sat May 03 14:37:57 2025 +0200
@@ -28,19 +28,29 @@
 #include "ascension/context.h"
 #include "ascension/error.h"
 
+#include <stdio.h>
+#include <stdarg.h>
 #include <cx/printf.h>
 
 #include <GL/glew.h>
 
+void asc_printf(const char *level, const char *file, unsigned line, const char *fmt, ...) {
+    printf("[%s %s %u] ", level, file, line);
+    va_list ap;
+    va_start(ap, fmt);
+    vprintf(fmt, ap);
+    va_end(ap);
+    putchar('\n');
+}
 
 void asc_error_impl(const char* file, unsigned line, char const* fmt, ...) {
     asc_set_flag(asc_context.flags, ASC_FLAG_HAS_ERROR);
 
     // write to error buffer
+    CxBuffer* buf = &asc_context.error_buffer;
+    size_t bufpos = buf->pos;
     va_list args;
     va_start(args, fmt);
-    CxBuffer* buf = &asc_context.error_buffer;
-    size_t bufpos = buf->pos;
     int written = cx_vfprintf(buf, cxBufferWriteFunc, fmt, args);
     cxBufferPut(buf, '\n');
     va_end(args);

mercurial