From b67674b0e53225416ca43724726351187222e9df Mon Sep 17 00:00:00 2001 From: Kamil Tomsik Date: Fri, 16 Aug 2024 11:20:01 +0200 Subject: [PATCH] util: fix log in tests --- src/util.zig | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/util.zig b/src/util.zig index 9c82515..2713369 100644 --- a/src/util.zig +++ b/src/util.zig @@ -1,6 +1,15 @@ +const builtin = @import("builtin"); const std = @import("std"); -pub const log = std.log.scoped(.fridge); +pub const log = if (builtin.is_test) struct { // zig build test captures stderr and there seems to be no f* way to disable it + pub fn debug(comptime fmt: []const u8, args: anytype) void { + std.debug.print("debug: " ++ fmt ++ "\n", args); + } + + pub fn err(comptime fmt: []const u8, args: anytype) void { + std.debug.print("err: " ++ fmt ++ "\n", args); + } +} else std.log.scoped(.fridge); pub fn tableName(comptime T: type) []const u8 { return comptime brk: {