chore: move fmt_buf into LogStruct
This commit is contained in:
parent
2b35755f6c
commit
d897a7ee86
|
@ -17,16 +17,14 @@ pub fn log(
|
||||||
|
|
||||||
fn LogStruct(c: anytype, comptime module_name: []const u8, comptime buf_size: usize) type {
|
fn LogStruct(c: anytype, comptime module_name: []const u8, comptime buf_size: usize) type {
|
||||||
return struct {
|
return struct {
|
||||||
|
threadlocal var fmt_buf: [buf_size]u8 = undefined;
|
||||||
|
|
||||||
pub fn log(
|
pub fn log(
|
||||||
comptime level: std.log.Level,
|
comptime level: std.log.Level,
|
||||||
comptime scope: @TypeOf(.EnumLiteral),
|
comptime scope: @TypeOf(.EnumLiteral),
|
||||||
comptime format: []const u8,
|
comptime format: []const u8,
|
||||||
args: anytype,
|
args: anytype,
|
||||||
) void {
|
) void {
|
||||||
const Buf = struct {
|
|
||||||
pub threadlocal var fmt_buf: [buf_size]u8 = undefined;
|
|
||||||
};
|
|
||||||
|
|
||||||
const g_level = switch (level) {
|
const g_level = switch (level) {
|
||||||
.err => c.G_LOG_LEVEL_CRITICAL,
|
.err => c.G_LOG_LEVEL_CRITICAL,
|
||||||
.warn => c.G_LOG_LEVEL_WARNING,
|
.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(
|
const s = std.fmt.bufPrintZ(
|
||||||
&Buf.fmt_buf,
|
&@This().fmt_buf,
|
||||||
format,
|
format,
|
||||||
args,
|
args,
|
||||||
) catch return;
|
) catch return;
|
||||||
|
|
Loading…
Reference in a new issue