From cf9e1e40a538821302f56ee6f5423e76a562b80f Mon Sep 17 00:00:00 2001 From: Don Park Date: Sat, 13 Jul 2024 20:24:56 +0700 Subject: [PATCH] get some logging going --- src/db/lmdb.zig | 2 +- src/main.zig | 1 + src/util.zig | 6 +----- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/db/lmdb.zig b/src/db/lmdb.zig index fead32d..aad712b 100644 --- a/src/db/lmdb.zig +++ b/src/db/lmdb.zig @@ -35,7 +35,7 @@ pub fn init(allocator: Allocator) !void { pub fn stats() void { var mdbStat: c.MDB_stat = undefined; _ = c.mdb_env_stat(env, &mdbStat); - warn("lmdb cache {} entries\n", .{mdbStat.ms_entries}); + util.log("lmdb cache {} entries\n", .{mdbStat.ms_entries}); } pub fn write(namespace: []const u8, key: []const u8, value: []const u8, allocator: Allocator) !void { diff --git a/src/main.zig b/src/main.zig index e267f60..0604086 100644 --- a/src/main.zig +++ b/src/main.zig @@ -39,6 +39,7 @@ pub fn main() !void { _ = thread.create("gui", gui.go, dummy_payload, guiback) catch unreachable; _ = thread.create("heartbeat", heartbeat.go, dummy_payload, heartback) catch unreachable; while (true) { + util.log("while", .{}); statewalk(alloc); util.log("thread.wait()/epoll", .{}); thread.wait(); // main ipc listener diff --git a/src/util.zig b/src/util.zig index 42241a3..efb1a0b 100644 --- a/src/util.zig +++ b/src/util.zig @@ -33,11 +33,7 @@ pub fn log(comptime msg: []const u8, args: anytype) void { var tz = std.posix.timezone{ .tz_minuteswest = 0, .tz_dsttime = 0 }; std.posix.gettimeofday(null, &tz); // does not set tz const time_str = "Z"; //std.fmt.allocPrint(alloc, "{d}-{d:0>2}-{d:0>2} {d:0>2}:{d:0>2}:{d:0>2}", .{ yday.year, mday.month.numeric(), mday.day_index + 1, dsec.getHoursIntoDay(), dsec.getMinutesIntoHour(), dsec.getSecondsIntoMinute() }) catch unreachable; - _ = time_str; - _ = tid_name; - _ = msg; - _ = args; - //std.debug.print("{s}[tid#{d}/{s:9}] " ++ msg ++ "\n", .{ time_str, tid, tid_name } ++ args); + std.debug.print("{s}[tid#{d}/{s:9}] " ++ msg ++ "\n", .{ time_str, tid, tid_name } ++ args); } pub fn hashIdSame(comptime T: type, a: T, b: T) bool {