about summary refs log tree commit diff
path: root/boot/common.c
diff options
context:
space:
mode:
Diffstat (limited to 'boot/common.c')
-rw-r--r--boot/common.c50
1 files changed, 49 insertions, 1 deletions
diff --git a/boot/common.c b/boot/common.c
index e453065..095aaa6 100644
--- a/boot/common.c
+++ b/boot/common.c
@@ -3,7 +3,7 @@
  * are used throughout the bootstrap compiler.
  * allocation done purely statically.
  *
- * Copyright (c) 2025, Mel G. <mel@rnrd.eu>
+ * Copyright (c) 2025-2026, Mel G. <mel@rnrd.eu>
  *
  * SPDX-License-Identifier: MPL-2.0
  */
@@ -127,6 +127,54 @@ unreachable()
     failure("unreachable code reached");
 }
 
+// log out a message with a debug prefix.
+// does not print additional \n at the end.
+void
+log_debug(const ascii* message, ...)
+{
+    fflush(stdout);
+    fprintf(stderr, ANSI_BOLD ANSI_CYAN "debug. " ANSI_NO_BOLD);
+
+    va_list args;
+    va_start(args, message);
+    vfprintf(stderr, message, args);
+    va_end(args);
+
+    fprintf(stderr, ANSI_RESET);
+}
+
+// log out a message with a warning prefix.
+// does not print additional \n at the end.
+void
+log_warning(const ascii* message, ...)
+{
+    fflush(stdout);
+    fprintf(stderr, ANSI_BOLD ANSI_YELLOW "warning? " ANSI_NO_BOLD);
+
+    va_list args;
+    va_start(args, message);
+    vfprintf(stderr, message, args);
+    va_end(args);
+
+    fprintf(stderr, ANSI_RESET);
+}
+
+// log out a message with an error prefix.
+// does not print additional \n at the end.
+void
+log_error(const ascii* message, ...)
+{
+    fflush(stdout);
+    fprintf(stderr, ANSI_BOLD ANSI_RED "error! " ANSI_NO_BOLD);
+
+    va_list args;
+    va_start(args, message);
+    vfprintf(stderr, message, args);
+    va_end(args);
+
+    fprintf(stderr, ANSI_RESET);
+}
+
 // for each entry in a linked list.
 #define FOR_EACH(type, cursor, head) for (type cursor = head; cursor != nil; cursor = cursor->next)