chore: move fmt_buf into LogStruct

This commit is contained in:
LordMZTE 2022-07-18 18:17:26 +02:00
parent 2b35755f6c
commit d897a7ee86
Signed by: LordMZTE
GPG key ID: B64802DC33A64FF6

View file

@ -17,16 +17,14 @@ pub fn log(
fn LogStruct(c: anytype, comptime module_name: []const u8, comptime buf_size: usize) type {
return struct {
threadlocal var fmt_buf: [buf_size]u8 = undefined;
pub fn log(
comptime level: std.log.Level,
comptime scope: @TypeOf(.EnumLiteral),
comptime format: []const u8,
args: anytype,
) void {
const Buf = struct {
pub threadlocal var fmt_buf: [buf_size]u8 = undefined;
};
const g_level = switch (level) {
.err => c.G_LOG_LEVEL_CRITICAL,
.warn => c.G_LOG_LEVEL_WARNING,
@ -35,7 +33,7 @@ fn LogStruct(c: anytype, comptime module_name: []const u8, comptime buf_size: us
};
const s = std.fmt.bufPrintZ(
&Buf.fmt_buf,
&@This().fmt_buf,
format,
args,
) catch return;