fix: incorrect typing

This commit is contained in:
LordMZTE 2022-07-18 17:32:43 +02:00
parent 1ebe62869b
commit 53c4751f31
Signed by: LordMZTE
GPG Key ID: B64802DC33A64FF6
1 changed files with 14 additions and 13 deletions

View File

@ -11,12 +11,11 @@ pub fn log(
/// The length of the buffer used for the formatted output.
/// This is the maximum length of log messages.
comptime buf_size: usize,
) fn (
comptime std.log.Level,
comptime @TypeOf(.EnumLiteral),
comptime format: []const u8,
anytype,
) void {
) @TypeOf(LogStruct(c, module_name, buf_size).log) {
return LogStruct(c, module_name, buf_size).log;
}
fn LogStruct(c: anytype, comptime module_name: []const u8, comptime buf_size: usize) type {
return struct {
pub fn log(
comptime level: std.log.Level,
@ -44,7 +43,14 @@ pub fn log(
var fields = [_]c.GLogField{
c.GLogField{
.key = "GLIB_DOMAIN",
.value = module_name ++ "-" ++ @tagName(scope),
.value = @ptrCast(
*const anyopaque,
// don't include scope name if not explicitly specified
if (std.mem.eql(u8, @tagName(scope), "default"))
module_name
else
module_name ++ "-" ++ @tagName(scope),
),
.length = -1,
},
c.GLogField{
@ -60,10 +66,5 @@ pub fn log(
fields.len,
);
}
}.log;
};
}
export fn add(a: i32, b: i32) i32 {
return a + b;
}