1const std = @import("std");
2const string = []const u8;
3const extras = @import("./lib.zig");
4
5pub fn LoggingReader(comptime T: type, comptime scope: @EnumLiteral()) type {
6 return struct {
7 child_stream: T,
8
9 pub const Error = T.Error;
10 pub const Reader = std.io.Reader(Self, Error, read);
11
12 const Self = @This();
13
14 pub fn init(child_stream: T) Self {
15 return .{
16 .child_stream = child_stream,
17 };
18 }
19
20 pub fn reader(self: Self) Reader {
21 return .{ .context = self };
22 }
23
24 fn read(self: Self, dest: []u8) Error!usize {
25 const n = try self.child_stream.read(dest);
26 std.log.scoped(scope).debug("{s}", .{dest[0..n]});
27 return n;
28 }
29 };
30}