mirror of
https://mzte.de/git/LordMZTE/dotfiles.git
synced 2024-06-01 12:57:37 +02:00
use zig-glib-log for playtwitch
This commit is contained in:
parent
75f953c6b6
commit
2f65edf3c1
2
justfile
2
justfile
|
@ -23,7 +23,7 @@ install-scripts target=(`echo $HOME` + "/.local/bin"): build-scripts
|
|||
|
||||
build-scripts:
|
||||
cd scripts/randomwallpaper && zig build -Drelease-fast
|
||||
cd scripts/playtwitch && zig build -Drelease-fast
|
||||
cd scripts/playtwitch && gyro build -Drelease-fast
|
||||
|
||||
install-lsps-paru:
|
||||
#!/bin/sh
|
||||
|
|
3
scripts/playtwitch/.gitignore
vendored
3
scripts/playtwitch/.gitignore
vendored
|
@ -1,2 +1,5 @@
|
|||
zig-cache/
|
||||
zig-out/
|
||||
deps.zig
|
||||
gyro.lock
|
||||
.gyro
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
const std = @import("std");
|
||||
const pkgs = @import("deps.zig").pkgs;
|
||||
|
||||
pub fn build(b: *std.build.Builder) void {
|
||||
// Standard target options allows the person running `zig build` to choose
|
||||
|
@ -17,6 +18,7 @@ pub fn build(b: *std.build.Builder) void {
|
|||
|
||||
exe.linkLibC();
|
||||
exe.linkSystemLibrary("gtk4");
|
||||
pkgs.addAllTo(exe);
|
||||
|
||||
exe.strip = mode != .Debug;
|
||||
|
||||
|
|
6
scripts/playtwitch/gyro.zzz
Normal file
6
scripts/playtwitch/gyro.zzz
Normal file
|
@ -0,0 +1,6 @@
|
|||
deps:
|
||||
glib-log:
|
||||
git:
|
||||
url: "https://mzte.de/git/LordMZTE/zig-glib-log.git"
|
||||
ref: master
|
||||
root: src/main.zig
|
|
@ -3,48 +3,7 @@ const ffi = @import("ffi.zig");
|
|||
const c = ffi.c;
|
||||
const gui = @import("gui.zig");
|
||||
|
||||
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: [512]u8 = undefined;
|
||||
};
|
||||
|
||||
const g_level = switch (level) {
|
||||
.err => c.G_LOG_LEVEL_ERROR,
|
||||
.warn => c.G_LOG_LEVEL_WARNING,
|
||||
.info => c.G_LOG_LEVEL_INFO,
|
||||
.debug => c.G_LOG_LEVEL_DEBUG,
|
||||
};
|
||||
|
||||
const s = std.fmt.bufPrintZ(
|
||||
&Buf.fmt_buf,
|
||||
format,
|
||||
args,
|
||||
) catch return;
|
||||
|
||||
var fields = [_]c.GLogField{
|
||||
c.GLogField{
|
||||
.key = "GLIB_DOMAIN",
|
||||
.value = "playtwitch-" ++ @tagName(scope),
|
||||
.length = -1,
|
||||
},
|
||||
c.GLogField{
|
||||
.key = "MESSAGE",
|
||||
.value = @ptrCast(*const anyopaque, s),
|
||||
.length = -1,
|
||||
},
|
||||
};
|
||||
|
||||
c.g_log_structured_array(
|
||||
g_level,
|
||||
&fields,
|
||||
fields.len,
|
||||
);
|
||||
}
|
||||
pub const log = @import("glib-log").log(c, "playtwitch", 512);
|
||||
|
||||
pub fn main() !u8 {
|
||||
var udata_arena = std.heap.ArenaAllocator.init(std.heap.c_allocator);
|
||||
|
|
Loading…
Reference in a new issue