diff options
author | Martin Ashby <martin@ashbysoft.com> | 2023-09-03 20:32:51 +0100 |
---|---|---|
committer | Martin Ashby <martin@ashbysoft.com> | 2023-09-03 20:32:51 +0100 |
commit | 2c4ac3819b8c42de1410fd524c2c9d08d937ec70 (patch) | |
tree | 570d63ee4c92d69c96c5d21bfb2be3adb35376a6 /src/log.zig | |
download | sql-zig-main.tar.gz sql-zig-main.tar.bz2 sql-zig-main.tar.xz sql-zig-main.zip |
Diffstat (limited to 'src/log.zig')
-rw-r--r-- | src/log.zig | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/log.zig b/src/log.zig new file mode 100644 index 0000000..dd81d5f --- /dev/null +++ b/src/log.zig @@ -0,0 +1,18 @@ +const std = @import("std"); +const builtin = @import("builtin"); +/// Workaround for failing tests when errors are logged +/// https://github.com/ziglang/zig/issues/5738#issuecomment-1466902082 +pub fn scoped_log_t(comptime scope: @Type(.EnumLiteral)) type { + return if (builtin.is_test) + // Downgrade `err` to `warn` for tests. + // Zig fails any test that does `log.err`, but we want to test those code paths here. + struct { + pub const base = std.log.scoped(scope); + pub const err = warn; + pub const warn = base.warn; + pub const info = base.info; + pub const debug = base.debug; + } + else + std.log.scoped(scope); +} |