| 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,8 +10,8 @@ pub fn init_thread() !void {} |
| 10 | 10 | ||
| 11 | pub fn deinit_thread() void {} | 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 | log.debug("{s}:{d}:{d} ({s})", .{ ctx.src.file, ctx.src.line, ctx.src.column, ctx.src.fn_name }); | 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 | pub inline fn trace_end(ctx: tracer.Ctx) void { | 17 | pub inline fn trace_end(ctx: tracer.Ctx) void { |
src/main.zig+1-1| ... | @@ -24,6 +24,6 @@ pub fn main() !void { | ... | @@ -24,6 +24,6 @@ pub fn main() !void { |
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | fn handler() void { | 26 | fn handler() void { |
| 27 | const t = tracer.trace(@src()); | 27 | const t = tracer.trace(@src(), "", .{}); |
| 28 | defer t.end(); | 28 | defer t.end(); |
| 29 | } | 29 | } |
src/mod.zig+2-2| ... | @@ -26,11 +26,11 @@ pub fn deinit_thread() void { | ... | @@ -26,11 +26,11 @@ pub fn deinit_thread() void { |
| 26 | impl.deinit_thread(); | 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 | const ctx = Ctx{ | 30 | const ctx = Ctx{ |
| 31 | .src = src, | 31 | .src = src, |
| 32 | }; | 32 | }; |
| 33 | if (started) impl.trace_begin(ctx); | 33 | if (started) impl.trace_begin(ctx, fmt, args); |
| 34 | return ctx; | 34 | return ctx; |
| 35 | } | 35 | } |
| 36 | 36 |
src/none.zig+3-1| ... | @@ -10,8 +10,10 @@ pub fn init_thread() !void {} | ... | @@ -10,8 +10,10 @@ pub fn init_thread() !void {} |
| 10 | 10 | ||
| 11 | pub fn deinit_thread() void {} | 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 | _ = ctx; | 14 | _ = ctx; |
| 15 | _ = ifmt; | ||
| 16 | _ = iargs; | ||
| 15 | } | 17 | } |
| 16 | 18 | ||
| 17 | pub inline fn trace_end(ctx: tracer.Ctx) void { | 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,8 +37,8 @@ pub fn deinit_thread() void { |
| 37 | log.debug("{s}", .{path}); | 37 | log.debug("{s}", .{path}); |
| 38 | } | 38 | } |
| 39 | 39 | ||
| 40 | pub inline fn trace_begin(ctx: tracer.Ctx) void { | 40 | pub inline fn trace_begin(ctx: tracer.Ctx, comptime ifmt: []const u8, iargs: anytype) void { |
| 41 | const fmt = "{s}:{d}:{d} ({s})"; | 41 | const fmt = "{s}:{d}:{d} ({s})" ++ ifmt; |
| 42 | const args = .{ | 42 | const args = .{ |
| 43 | if (ctx.src.file[0] == '/') ctx.src.file[trim_count..] else ctx.src.file, | 43 | if (ctx.src.file[0] == '/') ctx.src.file[trim_count..] else ctx.src.file, |
| 44 | ctx.src.line, | 44 | ctx.src.line, |
| ... | @@ -49,10 +49,10 @@ pub inline fn trace_begin(ctx: tracer.Ctx) void { | ... | @@ -49,10 +49,10 @@ pub inline fn trace_begin(ctx: tracer.Ctx) void { |
| 49 | .pid = @intCast(pid), | 49 | .pid = @intCast(pid), |
| 50 | .tid = @intCast(tid), | 50 | .tid = @intCast(tid), |
| 51 | .time = @floatFromInt(std.time.microTimestamp()), | 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 | .args_len = 0, | 53 | .args_len = 0, |
| 54 | }) catch return; | 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 | pub inline fn trace_end(ctx: tracer.Ctx) void { | 58 | pub inline fn trace_end(ctx: tracer.Ctx) void { |