Function defaultLog [src]
The default implementation for the log function, custom log functions may
forward log messages to this function.
Prototype
pub fn defaultLog( comptime message_level: Level, comptime scope: @Type(.enum_literal), comptime format: []const u8, args: anytype, ) void
Parameters
message_level: Level
scope: @Type(.enum_literal)
format: []const u8
Source
pub fn defaultLog(
comptime message_level: Level,
comptime scope: @Type(.enum_literal),
comptime format: []const u8,
args: anytype,
) void {
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.lockStdErr();
defer std.debug.unlockStdErr();
nosuspend {
writer.print(level_txt ++ prefix2 ++ format ++ "\n", args) catch return;
bw.flush() catch return;
}
}