| ... | ... | @@ -137,8 +137,11 @@ pub fn defaultLogEnabled(comptime message_level: Level) bool { |
| 137 | 137 | return comptime logEnabled(message_level, default_log_scope); |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | | /// The default implementation for the log function, custom log functions may |
| 140 | /// The default implementation for the log function. Custom log functions may |
| 141 | 141 | /// forward log messages to this function. |
| 142 | /// |
| 143 | /// Uses a 64-byte buffer for formatted printing which is flushed before this |
| 144 | /// function returns. |
| 142 | 145 | pub fn defaultLog( |
| 143 | 146 | comptime message_level: Level, |
| 144 | 147 | comptime scope: @Type(.enum_literal), |
| ... | ... | @@ -147,16 +150,10 @@ pub fn defaultLog( |
| 147 | 150 | ) void { |
| 148 | 151 | const level_txt = comptime message_level.asText(); |
| 149 | 152 | const prefix2 = if (scope == .default) ": " else "(" ++ @tagName(scope) ++ "): "; |
| 150 | | const stderr = std.fs.File.stderr().deprecatedWriter(); |
| 151 | | var bw = std.io.bufferedWriter(stderr); |
| 152 | | const writer = bw.writer(); |
| 153 | | |
| 154 | | std.debug.lockStdErr(); |
| 155 | | defer std.debug.unlockStdErr(); |
| 156 | | nosuspend { |
| 157 | | writer.print(level_txt ++ prefix2 ++ format ++ "\n", args) catch return; |
| 158 | | bw.flush() catch return; |
| 159 | | } |
| 153 | var buffer: [64]u8 = undefined; |
| 154 | const stderr = std.debug.lockStderrWriter(&buffer); |
| 155 | defer std.debug.unlockStderrWriter(); |
| 156 | nosuspend stderr.print(level_txt ++ prefix2 ++ format ++ "\n", args) catch return; |
| 160 | 157 | } |
| 161 | 158 | |
| 162 | 159 | /// Returns a scoped logging namespace that logs all messages using the scope |