chor: update zig version
All checks were successful
Zig Project Action / Lint, Spell-check and test zig project (push) Successful in 55s
All checks were successful
Zig Project Action / Lint, Spell-check and test zig project (push) Successful in 55s
This commit is contained in:
19
src/root.zig
19
src/root.zig
@@ -17,6 +17,7 @@ fn logFn(
|
||||
.debug => "[\x1b[38;5;12mdebug\x1b[0m]",
|
||||
};
|
||||
const complete_format = level_txt ++ prefix ++ format ++ "\n";
|
||||
var buf: [128]u8 = undefined;
|
||||
if (comptime build_options.file.len != 0) {
|
||||
// TODO handle errors accordingly (i.e. panic?)
|
||||
// NOTE with zig 0.13.0 there is currently no way to open files to append (except to use libc or talk directly to posix, which this lib should not have to do)
|
||||
@@ -27,26 +28,26 @@ fn logFn(
|
||||
}) catch @panic("Failed to open and/or create configured log file");
|
||||
defer file.close();
|
||||
|
||||
var buffer = io.bufferedWriter(file.writer());
|
||||
defer buffer.flush() catch {};
|
||||
var buffer = file.writer(&buf);
|
||||
var writer = &buffer.interface;
|
||||
defer writer.flush() catch {};
|
||||
|
||||
const writer = buffer.writer();
|
||||
log_writing(writer, fmt, args);
|
||||
log_writing(writer, complete_format, args);
|
||||
}
|
||||
|
||||
if (comptime build_options.stderr) {
|
||||
var buffer = io.bufferedWriter(stderr().deprecatedWriter());
|
||||
defer buffer.flush() catch {};
|
||||
var buffer = stderr().writer(&buf);
|
||||
var writer = &buffer.interface;
|
||||
defer writer.flush() catch {};
|
||||
|
||||
std.debug.lockStdErr();
|
||||
defer std.debug.unlockStdErr();
|
||||
|
||||
const writer = buffer.writer();
|
||||
log_writing(writer, complete_format, args);
|
||||
}
|
||||
}
|
||||
|
||||
inline fn log_writing(writer: anytype, comptime format: []const u8, args: anytype) void {
|
||||
inline fn log_writing(writer: *std.Io.Writer, comptime format: []const u8, args: anytype) void {
|
||||
nosuspend {
|
||||
if (build_options.timestamp) log_timestamp(writer);
|
||||
writer.print(format, args) catch return;
|
||||
@@ -183,7 +184,7 @@ fn inner_format(object: anytype, comptime format: []const u8, options: fmt.Forma
|
||||
},
|
||||
else => try fmt.format(writer, "[]{s}: {any}", .{ @typeName(v.child), object }),
|
||||
},
|
||||
else => try fmt.format(writer, "{any}", .{object}),
|
||||
else => try fmt.format(writer, format, .{object}),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user