WIP: WIP, WIP

This commit is contained in:
2025-03-14 13:00:54 +02:00
parent 467e4a944a
commit bebdb21c4e
13 changed files with 639 additions and 147 deletions
+45 -6
View File
@@ -27,16 +27,55 @@ pub const log = struct {
writeFn = f;
}
pub fn info(comptime format: []const u8, args: anytype) void {
write(.info, format ++ "\r\n", args);
pub inline fn info(comptime format: []const u8, args: anytype) void {
write(.info, format, args);
}
pub inline fn debug(comptime format: []const u8, args: anytype) void {
write(.debug, format, args);
}
pub inline fn warn(comptime format: []const u8, args: anytype) void {
write(.warn, format, args);
}
pub inline fn err(comptime format: []const u8, args: anytype) void {
write(.err, format, args);
}
pub fn writeRaw(data: []const u8) void {
writeWrapperFn(void, data);
_ = writeWrapperFn(0, data) catch return;
}
pub fn write(level: Level, comptime format: []const u8, args: anytype) void {
_ = level;
writer.print(format, args) catch return;
pub fn write(comptime level: Level, comptime format: []const u8, args: anytype) void {
const prefix = comptime logPrefix(level);
const suffix = comptime logSuffix(level);
writer.print(prefix ++ format ++ suffix ++ "\r\n", args) catch return;
}
pub fn todo(comptime msg: []const u8, args: anytype) noreturn {
err("Not yet implemented: " ++ msg, args);
@panic("Not yet implemented");
}
pub fn panic(comptime msg: []const u8, args: anytype) noreturn {
err("PANIC: " ++ msg, args);
@panic("Explicit kernel panic");
}
fn logPrefix(comptime level: Level) []const u8 {
switch (level) {
.debug => return "",
.info => return "\x1B[1;36m",
.warn => return "\x1B[1;33m",
.err => return "\x1B[1;31m",
}
}
fn logSuffix(comptime level: Level) []const u8 {
if (level == .debug) {
return "";
} else {
return "\x1B[0m";
}
}
};