mirror of
https://github.com/lukasl-dev/zlog.git
synced 2026-01-29 14:47:50 +01:00
Simple structured logging in Zig (0.14).
- Zig 92.3%
- Nix 7.7%
|
|
||
|---|---|---|
| .github/workflows | ||
| src | ||
| .envrc | ||
| .gitignore | ||
| build.zig | ||
| build.zig.zon | ||
| flake.lock | ||
| flake.nix | ||
| LICENSE | ||
| README.md | ||
zlog
Small helper on top of Zig’s std.log that simplifies structured logging
without additional heap allocations.
Installation
- Zig 0.14.1+
- Add the dependency:
zig fetch --save git+https://github.com/lukasl-dev/zlog.git
- In your
build.zig:
const dep = b.dependency("zlog", .{ .target = target, .optimize = optimize });
exe.root_module.addImport("zlog", dep.module("zlog"));
Usage
const std = @import("std");
const zlog = @import("zlog");
pub fn main() void {
zlog.info("user logged in", .{ .user = "alice", .id = 1 });
zlog.scoped(.auth).debug("token issued", .{ .token = "abc123" });
}
Output:
info: user logged in. user=alice id=1
debug(auth): token issued. token=abc123