地圖 (Jido) is a lightweight Unix TUI file explorer designed for speed and simplicity.
1const std = @import("std");
2
3const Logger = struct {
4 const Self = @This();
5 const BufferedFileWriter = std.io.BufferedWriter(4096, std.fs.File.Writer);
6
7 stdout: BufferedFileWriter = undefined,
8 stderr: BufferedFileWriter = undefined,
9
10 pub fn init(self: *Self) void {
11 self.stdout = BufferedFileWriter{ .unbuffered_writer = std.io.getStdOut().writer() };
12 self.stderr = BufferedFileWriter{ .unbuffered_writer = std.io.getStdErr().writer() };
13 }
14
15 pub fn info(self: *Self, comptime format: []const u8, args: anytype) void {
16 self.stdout.writer().print(format ++ "\n", args) catch return;
17 self.stdout.flush() catch return;
18 }
19
20 pub fn debug(self: *Self, comptime format: []const u8, args: anytype) void {
21 self.stdout.writer().print("[DEBUG] " ++ format ++ "\n", args) catch return;
22 self.stdout.flush() catch return;
23 }
24
25 pub fn err(self: *Self, comptime format: []const u8, args: anytype) void {
26 self.stderr.writer().print(format ++ "\n", args) catch return;
27 self.stderr.flush() catch return;
28 }
29};
30
31pub var log: Logger = Logger{};