| author | |
| committer | |
| log | 39a43e1bacabb514e6479795899b097022789623 |
| tree | 747c3286703f62608e206085bf91029c45c7106b |
| parent | a715c0c693801013e99801c92f7500d2fcb97229 |
5 files changed, 12 insertions(+), 10 deletions(-)
src/log.zig+2-2| ... | ... | @@ -10,8 +10,8 @@ pub fn init_thread() !void {} |
| 10 | 10 | |
| 11 | 11 | pub fn deinit_thread() void {} |
| 12 | 12 | |
| 13 | pub inline fn trace_begin(ctx: tracer.Ctx) void { | |
| 14 | log.debug("{s}:{d}:{d} ({s})", .{ ctx.src.file, ctx.src.line, ctx.src.column, ctx.src.fn_name }); | |
| 13 | pub inline fn trace_begin(ctx: tracer.Ctx, comptime ifmt: []const u8, iargs: anytype) void { | |
| 14 | log.debug("{s}:{d}:{d} ({s})" ++ ifmt, .{ ctx.src.file, ctx.src.line, ctx.src.column, ctx.src.fn_name } ++ iargs); | |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | pub inline fn trace_end(ctx: tracer.Ctx) void { |
src/main.zig+1-1| ... | ... | @@ -24,6 +24,6 @@ pub fn main() !void { |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | fn handler() void { |
| 27 | const t = tracer.trace(@src()); | |
| 27 | const t = tracer.trace(@src(), "", .{}); | |
| 28 | 28 | defer t.end(); |
| 29 | 29 | } |
src/mod.zig+2-2| ... | ... | @@ -26,11 +26,11 @@ pub fn deinit_thread() void { |
| 26 | 26 | impl.deinit_thread(); |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | pub inline fn trace(src: std.builtin.SourceLocation) Ctx { | |
| 29 | pub inline fn trace(src: std.builtin.SourceLocation, comptime fmt: []const u8, args: anytype) Ctx { | |
| 30 | 30 | const ctx = Ctx{ |
| 31 | 31 | .src = src, |
| 32 | 32 | }; |
| 33 | if (started) impl.trace_begin(ctx); | |
| 33 | if (started) impl.trace_begin(ctx, fmt, args); | |
| 34 | 34 | return ctx; |
| 35 | 35 | } |
| 36 | 36 |
src/none.zig+3-1| ... | ... | @@ -10,8 +10,10 @@ pub fn init_thread() !void {} |
| 10 | 10 | |
| 11 | 11 | pub fn deinit_thread() void {} |
| 12 | 12 | |
| 13 | pub inline fn trace_begin(ctx: tracer.Ctx) void { | |
| 13 | pub inline fn trace_begin(ctx: tracer.Ctx, comptime ifmt: []const u8, iargs: anytype) void { | |
| 14 | 14 | _ = ctx; |
| 15 | _ = ifmt; | |
| 16 | _ = iargs; | |
| 15 | 17 | } |
| 16 | 18 | |
| 17 | 19 | pub inline fn trace_end(ctx: tracer.Ctx) void { |
src/spall.zig+4-4| ... | ... | @@ -37,8 +37,8 @@ pub fn deinit_thread() void { |
| 37 | 37 | log.debug("{s}", .{path}); |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | pub inline fn trace_begin(ctx: tracer.Ctx) void { | |
| 41 | const fmt = "{s}:{d}:{d} ({s})"; | |
| 40 | pub inline fn trace_begin(ctx: tracer.Ctx, comptime ifmt: []const u8, iargs: anytype) void { | |
| 41 | const fmt = "{s}:{d}:{d} ({s})" ++ ifmt; | |
| 42 | 42 | const args = .{ |
| 43 | 43 | if (ctx.src.file[0] == '/') ctx.src.file[trim_count..] else ctx.src.file, |
| 44 | 44 | ctx.src.line, |
| ... | ... | @@ -49,10 +49,10 @@ pub inline fn trace_begin(ctx: tracer.Ctx) void { |
| 49 | 49 | .pid = @intCast(pid), |
| 50 | 50 | .tid = @intCast(tid), |
| 51 | 51 | .time = @floatFromInt(std.time.microTimestamp()), |
| 52 | .name_len = @intCast(std.fmt.count(fmt, args)), | |
| 52 | .name_len = @intCast(std.fmt.count(fmt, args ++ iargs)), | |
| 53 | 53 | .args_len = 0, |
| 54 | 54 | }) catch return; |
| 55 | buffered_writer.writer().print(fmt, args) catch return; | |
| 55 | buffered_writer.writer().print(fmt, args ++ iargs) catch return; | |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | pub inline fn trace_end(ctx: tracer.Ctx) void { |