ReviewOS

also looking at this

craft-native/craft

fix(log): keep the terminal's colour, and let logging be turned off

#81
Merged glennmichael123 wants to merge fix/log-colour-and-off into main
4 files +126 -16
packages/zig/src/minimal.zigmodified+5-1
Changes to packages/zig/src/minimal.zig
@@ -455,7 +455,7 @@ fn configureLogging(options: cli.WindowOptions) !void {
455455 const level: craft.Log.LogLevel = if (options.log_level) |name| blk: {
456456 break :blk parseLogLevel(name) orelse {
457457 std.debug.print(
458 "Error: unknown --log-level '{s}' (expected debug, info, warn, error or fatal)\n",
458 "Error: unknown --log-level '{s}' (expected debug, info, warn, error, fatal or off)\n",
459459 .{name},
460460 );
461461 std.process.exit(1);
@@ -484,6 +484,7 @@ fn configureLogging(options: cli.WindowOptions) !void {
484484 .Warning => .warn,
485485 .Error => .err,
486486 .Fatal => .fatal,
487 .Off => .off,
487488 },
488489 // Timestamp and colour are the outer sink's job now; doubling them
489490 // would put two of each on every line.
@@ -514,6 +515,9 @@ fn parseLogLevel(name: []const u8) ?craft.Log.LogLevel {
514515 .{ "error", craft.Log.LogLevel.Error },
515516 .{ "err", craft.Log.LogLevel.Error },
516517 .{ "fatal", craft.Log.LogLevel.Fatal },
518 .{ "off", craft.Log.LogLevel.Off },
519 .{ "none", craft.Log.LogLevel.Off },
520 .{ "silent", craft.Log.LogLevel.Off },
517521 };
518522 inline for (table) |entry| {
519523 if (std.ascii.eqlIgnoreCase(name, entry[0])) return entry[1];