diff --git a/lib/std/log.zig b/lib/std/log.zig index 5c4650cc1c..0562d09c51 100644 --- a/lib/std/log.zig +++ b/lib/std/log.zig @@ -149,9 +149,15 @@ pub fn defaultLog( const level_txt = comptime message_level.asText(); const prefix2 = if (scope == .default) ": " else "(" ++ @tagName(scope) ++ "): "; const stderr = std.io.getStdErr().writer(); + var bw = std.io.bufferedWriter(stderr); + const writer = bw.writer(); + std.debug.getStderrMutex().lock(); defer std.debug.getStderrMutex().unlock(); - nosuspend stderr.print(level_txt ++ prefix2 ++ format ++ "\n", args) catch return; + nosuspend { + writer.print(level_txt ++ prefix2 ++ format ++ "\n", args) catch return; + bw.flush() catch return; + } } /// Returns a scoped logging namespace that logs all messages using the scope